From 79afab446770148fa7b16ff46abf03f97841f612 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Tue, 11 Feb 2025 10:26:29 +0100 Subject: [PATCH] SPE-2681: Safely close app in webview callback. + handle unused event from Printables. --- src/slic3r/GUI/WebViewPanel.cpp | 6 ++++-- src/slic3r/GUI/WebViewPanel.hpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/WebViewPanel.cpp b/src/slic3r/GUI/WebViewPanel.cpp index 2f3f17efb1..15fb080d40 100644 --- a/src/slic3r/GUI/WebViewPanel.cpp +++ b/src/slic3r/GUI/WebViewPanel.cpp @@ -595,9 +595,10 @@ void WebViewPanel::sys_color_changed() void WebViewPanel::on_app_quit_event(const std::string& message_data) { // MacOS only suplement for cmd+Q - wxGetApp().Exit(); + if (wxGetApp().mainframe) { + wxGetApp().mainframe->Close(); + } } - void WebViewPanel::on_app_minimize_event(const std::string& message_data) { // MacOS only suplement for cmd+M @@ -1150,6 +1151,7 @@ PrintablesWebViewPanel::PrintablesWebViewPanel(wxWindow* parent) m_events["reloadHomePage"] = std::bind(&PrintablesWebViewPanel::on_reload_event, this, std::placeholders::_1); m_events["appQuit"] = std::bind(&WebViewPanel::on_app_quit_event, this, std::placeholders::_1); m_events["appMinimize"] = std::bind(&WebViewPanel::on_app_minimize_event, this, std::placeholders::_1); + m_events["ready"] = std::bind(&PrintablesWebViewPanel::on_printables_event_dummy, this, std::placeholders::_1); } void PrintablesWebViewPanel::handle_message(const std::string& message) diff --git a/src/slic3r/GUI/WebViewPanel.hpp b/src/slic3r/GUI/WebViewPanel.hpp index 479c9ed06b..17d0a41710 100644 --- a/src/slic3r/GUI/WebViewPanel.hpp +++ b/src/slic3r/GUI/WebViewPanel.hpp @@ -210,6 +210,7 @@ protected: void define_css() override; private: void handle_message(const std::string& message); + void on_printables_event_dummy(const std::string& message_data) {} void on_printables_event_access_token_expired(const std::string& message_data); void on_reload_event(const std::string& message_data); void on_printables_event_print_gcode(const std::string& message_data);