fixes necessary for the default GUI log target to be used in Debug mode

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20180 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-04-13 02:22:00 +00:00
parent 8c9564b392
commit 376b18eac7
2 changed files with 52 additions and 54 deletions

View File

@@ -553,37 +553,24 @@ bool wxApp::Initialize()
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
wxTheColourDatabase->Initialize(); wxTheColourDatabase->Initialize();
#ifdef __WXDEBUG__ wxWinMacWindowList = new wxList(wxKEY_INTEGER);
#if wxUSE_LOG wxWinMacControlList = new wxList(wxKEY_INTEGER);
// flush the logged messages if any and install a 'safer' log target: the
// default one (wxLogGui) can't be used after the resources are freed just
// below and the user suppliedo ne might be even more unsafe (using any
// wxWindows GUI function is unsafe starting from now)
wxLog::DontCreateOnDemand();
// this will flush the old messages if any wxInitializeStockLists();
delete wxLog::SetActiveTarget(new wxLogStderr); wxInitializeStockObjects();
#endif // wxUSE_LOG
#endif
wxWinMacWindowList = new wxList(wxKEY_INTEGER); wxBitmap::InitStandardHandlers();
wxWinMacControlList = new wxList(wxKEY_INTEGER);
wxInitializeStockLists(); wxModule::RegisterModules();
wxInitializeStockObjects(); if (!wxModule::InitializeModules()) {
return FALSE;
}
wxBitmap::InitStandardHandlers(); wxMacCreateNotifierTable() ;
wxModule::RegisterModules(); UMAShowArrowCursor() ;
if (!wxModule::InitializeModules()) {
return FALSE;
}
wxMacCreateNotifierTable() ; return TRUE;
UMAShowArrowCursor() ;
return TRUE;
} }
bool wxApp::OnInitGui() bool wxApp::OnInitGui()
@@ -801,8 +788,15 @@ void wxStAppResource::OpenSharedLibraryResource(const void *initBlock)
theModule = NSModuleForSymbol(theSymbol); theModule = NSModuleForSymbol(theSymbol);
theLibPath = NSLibraryNameForModule(theModule); theLibPath = NSLibraryNameForModule(theModule);
// if we call wxLogDebug from here then, as wxTheApp hasn't been
// created yet when we're called from wxApp::Initialize(), wxLog
// is going to create a default stderr-based log target instead of
// the expected normal GUI one -- don't do it, if we really want
// to see this message just use fprintf() here
#if 0
wxLogDebug( wxT("wxMac library installation name is '%s'"), wxLogDebug( wxT("wxMac library installation name is '%s'"),
theLibPath ); theLibPath );
#endif
// allocate copy to replace .dylib.* extension with .rsrc // allocate copy to replace .dylib.* extension with .rsrc
theResPath = strdup(theLibPath); theResPath = strdup(theLibPath);
@@ -817,8 +811,10 @@ void wxStAppResource::OpenSharedLibraryResource(const void *initBlock)
// overwrite extension with ".rsrc" // overwrite extension with ".rsrc"
strcpy(theExt, ".rsrc"); strcpy(theExt, ".rsrc");
#if 0
wxLogDebug( wxT("wxMac resources file name is '%s'"), wxLogDebug( wxT("wxMac resources file name is '%s'"),
theResPath ); theResPath );
#endif
theErr = FSPathMakeRef((UInt8 *) theResPath, &theResRef, false); theErr = FSPathMakeRef((UInt8 *) theResPath, &theResRef, false);
if (theErr != noErr) { if (theErr != noErr) {
@@ -832,8 +828,11 @@ void wxStAppResource::OpenSharedLibraryResource(const void *initBlock)
&gSharedLibraryResource); &gSharedLibraryResource);
} }
if (theErr != noErr) { if (theErr != noErr) {
wxLogDebug( wxT("unable to open wxMac resource file '%s'"), #ifdef __WXDEBUG__
theResPath ); fprintf(stderr,
wxT("unable to open wxMac resource file '%s'\n"),
theResPath );
#endif // __WXDEBUG__
} }
// free duplicated resource file path // free duplicated resource file path

View File

@@ -553,37 +553,24 @@ bool wxApp::Initialize()
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
wxTheColourDatabase->Initialize(); wxTheColourDatabase->Initialize();
#ifdef __WXDEBUG__ wxWinMacWindowList = new wxList(wxKEY_INTEGER);
#if wxUSE_LOG wxWinMacControlList = new wxList(wxKEY_INTEGER);
// flush the logged messages if any and install a 'safer' log target: the
// default one (wxLogGui) can't be used after the resources are freed just
// below and the user suppliedo ne might be even more unsafe (using any
// wxWindows GUI function is unsafe starting from now)
wxLog::DontCreateOnDemand();
// this will flush the old messages if any wxInitializeStockLists();
delete wxLog::SetActiveTarget(new wxLogStderr); wxInitializeStockObjects();
#endif // wxUSE_LOG
#endif
wxWinMacWindowList = new wxList(wxKEY_INTEGER); wxBitmap::InitStandardHandlers();
wxWinMacControlList = new wxList(wxKEY_INTEGER);
wxInitializeStockLists(); wxModule::RegisterModules();
wxInitializeStockObjects(); if (!wxModule::InitializeModules()) {
return FALSE;
}
wxBitmap::InitStandardHandlers(); wxMacCreateNotifierTable() ;
wxModule::RegisterModules(); UMAShowArrowCursor() ;
if (!wxModule::InitializeModules()) {
return FALSE;
}
wxMacCreateNotifierTable() ; return TRUE;
UMAShowArrowCursor() ;
return TRUE;
} }
bool wxApp::OnInitGui() bool wxApp::OnInitGui()
@@ -801,8 +788,15 @@ void wxStAppResource::OpenSharedLibraryResource(const void *initBlock)
theModule = NSModuleForSymbol(theSymbol); theModule = NSModuleForSymbol(theSymbol);
theLibPath = NSLibraryNameForModule(theModule); theLibPath = NSLibraryNameForModule(theModule);
// if we call wxLogDebug from here then, as wxTheApp hasn't been
// created yet when we're called from wxApp::Initialize(), wxLog
// is going to create a default stderr-based log target instead of
// the expected normal GUI one -- don't do it, if we really want
// to see this message just use fprintf() here
#if 0
wxLogDebug( wxT("wxMac library installation name is '%s'"), wxLogDebug( wxT("wxMac library installation name is '%s'"),
theLibPath ); theLibPath );
#endif
// allocate copy to replace .dylib.* extension with .rsrc // allocate copy to replace .dylib.* extension with .rsrc
theResPath = strdup(theLibPath); theResPath = strdup(theLibPath);
@@ -817,8 +811,10 @@ void wxStAppResource::OpenSharedLibraryResource(const void *initBlock)
// overwrite extension with ".rsrc" // overwrite extension with ".rsrc"
strcpy(theExt, ".rsrc"); strcpy(theExt, ".rsrc");
#if 0
wxLogDebug( wxT("wxMac resources file name is '%s'"), wxLogDebug( wxT("wxMac resources file name is '%s'"),
theResPath ); theResPath );
#endif
theErr = FSPathMakeRef((UInt8 *) theResPath, &theResRef, false); theErr = FSPathMakeRef((UInt8 *) theResPath, &theResRef, false);
if (theErr != noErr) { if (theErr != noErr) {
@@ -832,8 +828,11 @@ void wxStAppResource::OpenSharedLibraryResource(const void *initBlock)
&gSharedLibraryResource); &gSharedLibraryResource);
} }
if (theErr != noErr) { if (theErr != noErr) {
wxLogDebug( wxT("unable to open wxMac resource file '%s'"), #ifdef __WXDEBUG__
theResPath ); fprintf(stderr,
wxT("unable to open wxMac resource file '%s'\n"),
theResPath );
#endif // __WXDEBUG__
} }
// free duplicated resource file path // free duplicated resource file path