use wxLogBuffer to ensure that we don't lose error messages during initialization; only switch to wxLogGui when it's really safe to use it
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34557 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -142,14 +142,6 @@ wxAppConsole::~wxAppConsole()
|
||||
|
||||
bool wxAppConsole::Initialize(int& argc, wxChar **argv)
|
||||
{
|
||||
#if wxUSE_LOG
|
||||
// If some code logged something before wxApp instance was created,
|
||||
// wxLogStderr was set as the target. Undo it here by destroying the
|
||||
// current target. It will be re-created next time logging is needed, but
|
||||
// this time wxAppTraits will be used:
|
||||
delete wxLog::SetActiveTarget(NULL);
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
// remember the command line arguments
|
||||
this->argc = argc;
|
||||
this->argv = argv;
|
||||
|
@@ -209,6 +209,15 @@ static void FreeConvertedArgs()
|
||||
// initialization which is always done (not customizable) before wxApp creation
|
||||
static bool DoCommonPreInit()
|
||||
{
|
||||
#if wxUSE_LOG
|
||||
// install temporary log sink: we can't use wxLogGui before wxApp is
|
||||
// constructed and if we use wxLogStderr, all messages during
|
||||
// initialization simply disappear under Windows
|
||||
//
|
||||
// note that we will delete this log target below
|
||||
wxLog::SetActiveTarget(new wxLogBuffer);
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -217,7 +226,13 @@ static bool DoCommonPostInit()
|
||||
{
|
||||
wxModule::RegisterModules();
|
||||
|
||||
return wxModule::InitializeModules();
|
||||
if ( !wxModule::InitializeModules() )
|
||||
{
|
||||
wxLogError(_("Initialization failed in post init, aborting."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxEntryStart(int& argc, wxChar **argv)
|
||||
@@ -286,6 +301,14 @@ bool wxEntryStart(int& argc, wxChar **argv)
|
||||
// and the cleanup object from doing cleanup
|
||||
callAppCleanup.Dismiss();
|
||||
|
||||
#if wxUSE_LOG
|
||||
// now that we have a valid wxApp (wxLogGui would have crashed if we used
|
||||
// it before now), we can delete the temporary sink we had created for the
|
||||
// initialization messages -- the next time logging function is called, the
|
||||
// sink will be recreated but this time wxAppTraits will be used
|
||||
delete wxLog::SetActiveTarget(NULL);
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -385,6 +408,8 @@ int wxEntryReal(int& argc, wxChar **argv)
|
||||
// library initialization
|
||||
if ( !wxEntryStart(argc, argv) )
|
||||
{
|
||||
// flush any log messages explaining why we failed
|
||||
delete wxLog::SetActiveTarget(NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user