Skip to content

Commit

Permalink
Delay first init() call in hints notifications.
Browse files Browse the repository at this point in the history
Fix of #9780
  • Loading branch information
kocikdav committed Feb 20, 2023
1 parent 4199d1a commit 6cb9947
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 14 additions & 2 deletions src/slic3r/GUI/HintNotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ void NotificationManager::HintNotification::open_documentation()
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);
if (hint_data == nullptr)
Expand All @@ -1060,8 +1060,20 @@ void NotificationManager::HintNotification::retrieve_data(bool new_hint/* = true
m_runtime_disable = hint_data->runtime_disable;
m_documentation_link = hint_data->documentation_link;
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 GUI
5 changes: 3 additions & 2 deletions src/slic3r/GUI/HintNotification.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ class NotificationManager::HintNotification : public NotificationManager::PopNot
HintNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler, bool new_hint)
: PopNotification(n, id_provider, evt_handler)
{
retrieve_data(new_hint);
retrieve_data(new_hint, true);
}
virtual void init() override;
void open_next() { retrieve_data(); }
void update_hint(const NotificationData& n, bool constructuctor_call);
protected:
virtual void set_next_window_size(ImGuiWrapper& imgui) override;
virtual void count_spaces() override;
Expand All @@ -101,7 +102,7 @@ class NotificationManager::HintNotification : public NotificationManager::PopNot
const float win_size_x, const float win_size_y,
const float win_pos_x, const float win_pos_y);
// 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();

bool m_has_hint_data { false };
Expand Down

0 comments on commit 6cb9947

Please sign in to comment.