lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 75780fdb 5/5: Simplify safe_message_alert() a


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 75780fdb 5/5: Simplify safe_message_alert() and make it more portable
Date: Wed, 22 Feb 2023 18:09:53 -0500 (EST)

branch: master
commit 75780fdb9cfb98a3edf7a28732aab91bbe9c466e
Author: Vadim Zeitlin <vadim@tt-solutions.com>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Simplify safe_message_alert() and make it more portable
    
    Show message box under non-MSW platforms too if it can be done safely by
    using the function behind wxSafeShowMessage() implementation, even if we
    can't use this function itself here if we want to preserve the current
    behaviour exactly (see the previous commit message for more details).
    
    Remove the outdated comment documenting wxSafeShowMessage() shortcomings
    that don't apply to the current versions of wxWidgets any longer.
---
 alert_wx.cpp | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/alert_wx.cpp b/alert_wx.cpp
index c28042ca..02f90208 100644
--- a/alert_wx.cpp
+++ b/alert_wx.cpp
@@ -138,35 +138,12 @@ void alarum_alert(std::string const& s)
 
 /// Show a message reliably, even before initialization has finished
 /// or after termination has begun.
-///
-/// The msw implementation of wxSafeShowMessage() uses ::MessageBoxA()
-/// with a null parent, which adds an undesirable extra "task" to the
-/// alt-Tab order, yet doesn't disable the application's top window.
-///
-/// If MB_TASKMODAL is specified, then the extra "task" is still
-/// added, but all of the application's top windows are disabled.
-/// Unfortunately, MB_TASKMODAL is in effect ignored unless the parent
-/// is null.
-///
-/// If the main top window (the one returned by wxApp::GetTopWindow())
-/// is used as the messagebox's parent, then the extra "task" is not
-/// added, but only the parent is disabled. Any other top windows the
-/// application may have are not disabled.
-///
-/// The extra "task" seeming to be the worse evil, this implementation
-/// specifies a non-null parent wherever possible. MB_TASKMODAL is
-/// nevertheless specified as well, though its beneficial effect is
-/// realized only if no parent can be found.
 
 void safe_message_alert(char const* message)
 {
+    // We don't use wxSafeShowMessage() here for the same reasons as in
+    // warning_alert() above.
     safely_show_on_stderr(message);
-#if defined LMI_MSW
-    auto handle =
-        (wxTheApp && wxTheApp->GetTopWindow())
-        ? wxTheApp->GetTopWindow()->GetHandle()
-        : nullptr
-        ;
-    ::MessageBoxA(handle, message, "Error", MB_OK | MB_ICONSTOP | 
MB_TASKMODAL);
-#endif // defined LMI_MSW
+
+    wxApp::GetValidTraits().SafeMessageBox(message, "Error");
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]