git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34557
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
bool wxAppConsole::Initialize(int& argc, wxChar **argv)
{
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;
// remember the command line arguments
this->argc = argc;
this->argv = argv;
// initialization which is always done (not customizable) before wxApp creation
static bool DoCommonPreInit()
{
// 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
+
{
wxModule::RegisterModules();
{
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)
}
bool wxEntryStart(int& argc, wxChar **argv)
// and the cleanup object from doing cleanup
callAppCleanup.Dismiss();
// 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
+
// library initialization
if ( !wxEntryStart(argc, argv) )
{
// library initialization
if ( !wxEntryStart(argc, argv) )
{
+ // flush any log messages explaining why we failed
+ delete wxLog::SetActiveTarget(NULL);