X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/74698d3a22d5e611bbcd731a3ade616c66cfaca6..de505a9e23cfaa4ada2bf972290f7d15a9424270:/src/common/appcmn.cpp diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index 1018cbae7c..fec6879ea6 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -84,8 +84,21 @@ wxAppBase::wxAppBase() #if wxUSE_GUI m_topWindow = (wxWindow *)NULL; m_useBestVisual = FALSE; - m_exitOnFrameDelete = TRUE; m_isActive = TRUE; + + // We don't want to exit the app if the user code shows a dialog from its + // OnInit() -- but this is what would happen if we set m_exitOnFrameDelete + // to Yes initially as this dialog would be the last top level window. + // OTOH, if we set it to No initially we'll have to overwrite it with Yes + // when we enter our OnRun() because we do want the default behaviour from + // then on. But this would be a problem if the user code calls + // SetExitOnFrameDelete(FALSE) from OnInit(). + // + // So we use the special "Later" value which is such that + // GetExitOnFrameDelete() returns FALSE for it but which we know we can + // safely (i.e. without losing the effect of the users SetExitOnFrameDelete + // call) overwrite in OnRun() + m_exitOnFrameDelete = Later; #endif // wxUSE_GUI #ifdef __WXDEBUG__ @@ -99,6 +112,7 @@ wxAppBase::~wxAppBase() } #if wxUSE_GUI + bool wxAppBase::OnInitGui() { #ifdef __WXUNIVERSAL__ @@ -111,6 +125,20 @@ bool wxAppBase::OnInitGui() return TRUE; } + +int wxAppBase::OnRun() +{ + // see the comment in ctor: if the initial value hasn't been changed, use + // the default Yes from now on + if ( m_exitOnFrameDelete == Later ) + { + m_exitOnFrameDelete = Yes; + } + //else: it has been changed, assume the user knows what he is doing + + return MainLoop(); +} + #endif // wxUSE_GUI int wxAppBase::OnExit() @@ -191,8 +219,15 @@ int wxAppBase::FilterEvent(wxEvent& WXUNUSED(event)) void wxAppBase::DoInit() { - if(wxMessageOutput::Get()) return; -#if wxUSE_GUI + if (wxMessageOutput::Get()) + return; + + // NB: The standard way of printing help on command line arguments (app --help) + // is (according to common practice): + // - console apps: to stderr (on any platform) + // - GUI apps: stderr on Unix platforms (!) + // message box under Windows and others +#if wxUSE_GUI && !defined(__UNIX__) #ifdef __WXMOTIF__ wxMessageOutput::Set(new wxMessageOutputLog); #else