From 6cb99470664d4d493992c4fe2925aa43268c7a4e Mon Sep 17 00:00:00 2001 From: David Kocik Date: Mon, 20 Feb 2023 14:47:02 +0100 Subject: [PATCH] Delay first init() call in hints notifications. Fix of #9780 --- src/slic3r/GUI/HintNotification.cpp | 16 ++++++++++++++-- src/slic3r/GUI/HintNotification.hpp | 5 +++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/HintNotification.cpp b/src/slic3r/GUI/HintNotification.cpp index 1f3d224919e..8f81d90f513 100644 --- a/src/slic3r/GUI/HintNotification.cpp +++ b/src/slic3r/GUI/HintNotification.cpp @@ -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) @@ -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 diff --git a/src/slic3r/GUI/HintNotification.hpp b/src/slic3r/GUI/HintNotification.hpp index e5dd90bdbd1..efcdb12a757 100644 --- a/src/slic3r/GUI/HintNotification.hpp +++ b/src/slic3r/GUI/HintNotification.hpp @@ -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; @@ -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 };