]> git.saurik.com Git - wxWidgets.git/commitdiff
call OnExit() even if an exception has been thrown from OnRun()
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 20 Sep 2003 16:18:19 +0000 (16:18 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 20 Sep 2003 16:18:19 +0000 (16:18 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23741 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/init.cpp

index 774cbd2273c042793491bc2ff680ef9c9c61c52e..15cca2da329b4794f78a1fe44969d5681bb7ff3f 100644 (file)
@@ -403,13 +403,15 @@ int wxEntryReal(int& argc, wxChar **argv)
             return -1;
         }
 
-        // app execution
-        int retValue = wxTheApp->OnRun();
-
-        // app clean up
-        wxTheApp->OnExit();
+        // ensure that OnExit() is called if OnInit() had succeeded
+        class CallOnExit
+        {
+        public:
+            ~CallOnExit() { wxTheApp->OnExit(); }
+        } callOnExit;
 
-        return retValue;
+        // app execution
+        return wxTheApp->OnRun();
     }
     wxCATCH_ALL( wxTheApp->OnUnhandledException(); return -1; )
 }