lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [6099] Don't complain about unclosed documents during stac


From: Greg Chicares
Subject: [lmi-commits] [6099] Don't complain about unclosed documents during stack unwinding
Date: Fri, 23 Jan 2015 15:37:17 +0000

Revision: 6099
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6099
Author:   chicares
Date:     2015-01-23 15:37:16 +0000 (Fri, 23 Jan 2015)
Log Message:
-----------
Don't complain about unclosed documents during stack unwinding

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/wx_test_new.hpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2015-01-23 15:26:12 UTC (rev 6098)
+++ lmi/trunk/ChangeLog 2015-01-23 15:37:16 UTC (rev 6099)
@@ -35599,3 +35599,9 @@
 Fail if an unexpected modal dialog is about to be shown. See:
   http://lists.nongnu.org/archive/html/lmi/2014-12/msg00097.html
 
+20150123T1537Z <address@hidden> [516]
+
+  wx_test_new.hpp
+Don't complain about unclosed documents during stack unwinding. See:
+  http://lists.nongnu.org/archive/html/lmi/2014-12/msg00097.html
+

Modified: lmi/trunk/wx_test_new.hpp
===================================================================
--- lmi/trunk/wx_test_new.hpp   2015-01-23 15:26:12 UTC (rev 6098)
+++ lmi/trunk/wx_test_new.hpp   2015-01-23 15:37:16 UTC (rev 6099)
@@ -33,6 +33,8 @@
 #include <wx/testing.h>
 #include <wx/uiaction.h>
 
+#include <exception>
+
 /// Helper base class for classes testing creation of specific new documents.
 ///
 /// This class provides methods for closing the current document, optionally
@@ -55,15 +57,32 @@
 
     ~wx_test_new_document_base()
     {
-        // As we don't want to throw an exception from the dtor, all we can do
-        // is to complain to the user directly.
+        // Normally either close() or close_discard_changes() should be called,
+        // so complain about forgetting to do this if neither was. Except that
+        // we shouldn't do this if we're unwinding due to an exception from a
+        // test failure, as this is not a bug in the test code then.
         if(opened_)
             {
-            wxSafeShowMessage
-                ("Programming error"
-                ,"A document created during unattended test hasn't been 
closed, "
-                 "please report this."
-                );
+            if(std::uncaught_exception())
+                {
+                // Moreover, in case of exception, try to close the window to
+                // avoid showing message boxes asking the user if it should be
+                // saved: this is undesirable in an unattended test.
+                do_close();
+
+                wxTEST_DIALOG
+                    (wxYield()
+                    ,wxExpectModal<wxMessageDialog>(wxNO).Optional()
+                    );
+                }
+            else
+                {
+                wxSafeShowMessage
+                    ("Programming error"
+                    ,"A document created during unattended test hasn't been 
closed, "
+                     "please report this."
+                    );
+                }
             }
     }
 




reply via email to

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