Delay first init() call in hints notifications.

Fix of #9780
This commit is contained in:
David Kocik 2023-02-20 14:47:02 +01:00
parent 4199d1aef6
commit 6cb9947066
2 changed files with 17 additions and 4 deletions

View File

@ -1040,7 +1040,7 @@ void NotificationManager::HintNotification::open_documentation()
launch_browser_if_allowed(m_documentation_link); launch_browser_if_allowed(m_documentation_link);
} }
} }
void NotificationManager::HintNotification::retrieve_data(bool new_hint/* = true*/) void NotificationManager::HintNotification::retrieve_data(bool new_hint/* = true*/, bool constructuctor_call/* = false*/)
{ {
HintData* hint_data = HintDatabase::get_instance().get_hint(new_hint); HintData* hint_data = HintDatabase::get_instance().get_hint(new_hint);
if (hint_data == nullptr) if (hint_data == nullptr)
@ -1060,8 +1060,20 @@ void NotificationManager::HintNotification::retrieve_data(bool new_hint/* = true
m_runtime_disable = hint_data->runtime_disable; m_runtime_disable = hint_data->runtime_disable;
m_documentation_link = hint_data->documentation_link; m_documentation_link = hint_data->documentation_link;
m_has_hint_data = true; m_has_hint_data = true;
update(nd); update_hint(nd, constructuctor_call);
} }
} }
void NotificationManager::HintNotification::update_hint(const NotificationData& n, bool constructuctor_call)
{
m_text1 = n.text1;
m_hypertext = n.hypertext;
m_text2 = n.text2;
// This call to init was crashing PS. See issue #9780.
// When Hint notification is created in GuiApp::post_init, it is possible, that imgui was not initialized yet.
// This happens if first idle event is recieved earlier then focus event. Which seems to be happening on some MacOS Ventura 13.1+.
// This condition should prevent it.
if (!constructuctor_call)
init();
}
} //namespace Slic3r } //namespace Slic3r
} //namespace GUI } //namespace GUI

View File

@ -72,10 +72,11 @@ public:
HintNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler, bool new_hint) HintNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler, bool new_hint)
: PopNotification(n, id_provider, evt_handler) : PopNotification(n, id_provider, evt_handler)
{ {
retrieve_data(new_hint); retrieve_data(new_hint, true);
} }
virtual void init() override; virtual void init() override;
void open_next() { retrieve_data(); } void open_next() { retrieve_data(); }
void update_hint(const NotificationData& n, bool constructuctor_call);
protected: protected:
virtual void set_next_window_size(ImGuiWrapper& imgui) override; virtual void set_next_window_size(ImGuiWrapper& imgui) override;
virtual void count_spaces() override; virtual void count_spaces() override;
@ -101,7 +102,7 @@ protected:
const float win_size_x, const float win_size_y, const float win_size_x, const float win_size_y,
const float win_pos_x, const float win_pos_y); const float win_pos_x, const float win_pos_y);
// recursion counter -1 tells to retrieve same hint as last time // recursion counter -1 tells to retrieve same hint as last time
void retrieve_data(bool new_hint = true); void retrieve_data(bool new_hint = true, bool constructuctor_call = false);
void open_documentation(); void open_documentation();
bool m_has_hint_data { false }; bool m_has_hint_data { false };