From d74a9ac286654bc8b4bec1e27d02a2d578f8b12c Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Tue, 22 Apr 2025 14:22:00 +0800 Subject: [PATCH] FIX: protect the EndModal functions while top dialog is not this one. jira: [STUDIO-11503] [STUDIO-11522] Change-Id: I02bf784fa7c796a75525deb79f8287027780bc69 --- src/slic3r/GUI/GUI_Utils.hpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index 8d9f89d48..d008b850a 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -337,7 +338,26 @@ private: }; typedef DPIAware DPIFrame; -typedef DPIAware DPIDialog; +class DPIDialog : public DPIAware +{ +public: + using DPIAware::DPIAware; + +public: + void EndModal(int retCode) override + { + if (!dialogStack.empty() && dialogStack.front() != this) { + // This is a bug in wxWidgets + // when the dialog is not top modal dialog, EndModal() just hide dialog without quit + // the modal event loop. And the modal event loop blocks us from bottom widgets. + // Solution: let user click it manually or close outside. FIXME + BOOST_LOG_TRIVIAL(warning) << "DPIAware::EndModal Error: dialogStack is not empty, but top dialog is not this one. retCode=" << retCode; + return; + } + + return wxDialog::EndModal(retCode); + } +}; class EventGuard