lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [6583] Prevent crash if GUI test aborted (VZ)


From: gchicares
Subject: [lmi-commits] [6583] Prevent crash if GUI test aborted (VZ)
Date: Thu, 12 May 2016 15:48:18 +0000 (UTC)

Revision: 6583
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6583
Author:   chicares
Date:     2016-05-12 15:48:17 +0000 (Thu, 12 May 2016)
Log Message:
-----------
Prevent crash if GUI test aborted (VZ)

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/main_wx_test.cpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2016-05-12 00:50:23 UTC (rev 6582)
+++ lmi/trunk/ChangeLog 2016-05-12 15:48:17 UTC (rev 6583)
@@ -39100,3 +39100,9 @@
   progress_meter.hpp
 Suppress a clang warning.
 
+20160512T1548Z <address@hidden> [451]
+
+  main_wx_test.cpp
+Prevent crash if GUI test aborted (VZ). See:
+  https://github.com/vadz/lmi/pull/24/
+

Modified: lmi/trunk/main_wx_test.cpp
===================================================================
--- lmi/trunk/main_wx_test.cpp  2016-05-12 00:50:23 UTC (rev 6582)
+++ lmi/trunk/main_wx_test.cpp  2016-05-12 15:48:17 UTC (rev 6583)
@@ -46,7 +46,6 @@
 #include <wx/frame.h>
 #include <wx/init.h>                    // wxEntry()
 #include <wx/msgdlg.h>
-#include <wx/scopeguard.h>
 #include <wx/stopwatch.h>
 #include <wx/testing.h>
 #include <wx/uiaction.h>
@@ -803,8 +802,30 @@
 
     // Whatever happens, ensure that the main window is closed and thus the
     // main loop terminated and the application exits at the end of the tests.
-    wxON_BLOCK_EXIT_OBJ1(*mainWin, wxWindow::Close, true /* force close */);
+    class ensure_top_window_closed
+    {
+      public:
+        explicit ensure_top_window_closed(wxApp* app)
+            :app_(app)
+        {
+        }
 
+        ensure_top_window_closed(ensure_top_window_closed const&) = delete;
+        ensure_top_window_closed& operator=(ensure_top_window_closed const&) = 
delete;
+
+        ~ensure_top_window_closed()
+        {
+        wxWindow* const top = app_->GetTopWindow();
+        if(top)
+            {
+            top->Close(true /* force close */);
+            }
+        }
+
+      private:
+        wxApp const* const app_;
+    } close_top_window_on_scope_exit(this);
+
     // Close any initially opened dialogs (e.g. "About" dialog shown unless a
     // special command line option is specified).
     for (;;)




reply via email to

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