]> git.saurik.com Git - wxWidgets.git/commitdiff
allow people use modal dialogs in wxApp::OnInit
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 11 Jan 2001 22:11:54 +0000 (22:11 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 11 Jan 2001 22:11:54 +0000 (22:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9081 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/app.cpp

index 97db7145272cab692b6f4010f8d1db509283eda1..399e734e84ed96bc1b1a7b982d2fd430af7ee2a9 100644 (file)
@@ -724,15 +724,33 @@ int wxEntry(WXHINSTANCE hInstance,
 
         int retValue = 0;
 
-        if ( wxTheApp->OnInit() )
+        // it is common to create a modal dialog in OnInit() (to ask/notify the
+        // user about something) but it wouldn't work if we don't change the
+        // "exit on delete last frame" flag here as when this dialog is
+        // deleted, the app would terminate (it was the last top level window
+        // as the main frame wasn't created yet!), so disable this behaviour
+        // temproarily
+        bool exitOnLastFrameDelete = wxTheApp->GetExitOnFrameDelete();
+        wxTheApp->SetExitOnFrameDelete(FALSE);
+
+        // init the app
+        retValue = wxTheApp->OnInit() ? 0 : -1;
+
+        // restore the old flag value
+        wxTheApp->SetExitOnFrameDelete(exitOnLastFrameDelete);
+
+        if ( retValue == 0 )
         {
             if ( enterLoop )
             {
+                // run the main loop
                 retValue = wxTheApp->OnRun();
             }
             else
-                // We want to initialize, but not run or exit immediately.
+            {
+                // we want to initialize, but not run or exit immediately.
                 return 1;
+            }
         }
         //else: app initialization failed, so we skipped OnRun()