From 6afafc42fcf42ce84c9e1c0a7c00d3a0376d1aef Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 11 Jan 2001 22:11:54 +0000 Subject: [PATCH] allow people use modal dialogs in wxApp::OnInit git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9081 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/app.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 97db714527..399e734e84 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -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() -- 2.47.2