more work on fixing wxEntry() and ANSI/Unicode cmd line args mess
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21520 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -95,7 +95,7 @@ public:
|
||||
// reason, you must override it (instead of just overriding OnInit(), as
|
||||
// usual, for app-specific initializations), do not forget to call the base
|
||||
// class version!
|
||||
virtual bool Initialize(int argc, wxChar **argv);
|
||||
virtual bool Initialize(int& argc, wxChar **argv);
|
||||
|
||||
// Called before OnRun(), this is a good place to do initialization -- if
|
||||
// anything fails, return false from here to prevent the program from
|
||||
@@ -314,7 +314,7 @@ public:
|
||||
// very first initialization function
|
||||
//
|
||||
// Override: very rarely
|
||||
virtual bool Initialize(int argc, wxChar **argv);
|
||||
virtual bool Initialize(int& argc, wxChar **argv);
|
||||
|
||||
// a platform-dependent version of OnInit(): the code here is likely to
|
||||
// depend on the toolkit. default version does nothing.
|
||||
|
@@ -66,7 +66,7 @@ public:
|
||||
// Returns TRUE if more idle time is requested.
|
||||
bool SendIdleEvents(wxWindowCocoa* win);
|
||||
|
||||
virtual bool Initialize(int argc, wxChar **argv);
|
||||
virtual bool Initialize(int& argc, wxChar **argv);
|
||||
virtual void CleanUp();
|
||||
|
||||
virtual bool OnInit();
|
||||
|
@@ -58,7 +58,7 @@ public:
|
||||
bool SendIdleEvents();
|
||||
bool SendIdleEvents( wxWindow* win );
|
||||
|
||||
virtual bool Initialize(int argc, wxChar **argv);
|
||||
virtual bool Initialize(int& argc, wxChar **argv);
|
||||
virtual void CleanUp();
|
||||
|
||||
static bool InitialzeVisual();
|
||||
|
@@ -58,7 +58,7 @@ public:
|
||||
bool SendIdleEvents();
|
||||
bool SendIdleEvents( wxWindow* win );
|
||||
|
||||
virtual bool Initialize(int argc, wxChar **argv);
|
||||
virtual bool Initialize(int& argc, wxChar **argv);
|
||||
virtual void CleanUp();
|
||||
|
||||
static bool InitialzeVisual();
|
||||
|
@@ -24,8 +24,9 @@
|
||||
// this function also creates wxTheApp as a side effect, if IMPLEMENT_APP
|
||||
// hadn't been used a dummy default application object is created
|
||||
//
|
||||
// note that the parameters may be modified
|
||||
extern bool WXDLLEXPORT wxEntryStart(int argc, wxChar **argv);
|
||||
// note that the parameters may be modified, this is why we pass them by
|
||||
// reference!
|
||||
extern bool WXDLLEXPORT wxEntryStart(int& argc, wxChar **argv);
|
||||
|
||||
// free the resources allocated by the library in wxEntryStart() and shut it
|
||||
// down (wxEntryStart() may be called again afterwards if necessary)
|
||||
@@ -41,7 +42,7 @@ extern void WXDLLEXPORT wxEntryCleanup();
|
||||
// but this one always exists under all platforms
|
||||
//
|
||||
// returns the program exit code
|
||||
extern int WXDLLEXPORT wxEntry(int argc, wxChar **argv);
|
||||
extern int WXDLLEXPORT wxEntry(int& argc, wxChar **argv);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -91,7 +91,7 @@ protected:
|
||||
public:
|
||||
|
||||
// Implementation
|
||||
virtual bool Initialize(int argc, wxChar **argv);
|
||||
virtual bool Initialize(int& argc, wxChar **argv);
|
||||
virtual void CleanUp();
|
||||
|
||||
bool IsExiting() { return !m_keepGoing ; }
|
||||
|
@@ -54,7 +54,7 @@ public:
|
||||
bool SendIdleEvents();
|
||||
bool SendIdleEvents(wxWindow* win);
|
||||
|
||||
virtual bool Initialize(int argc, wxChar **argv);
|
||||
virtual bool Initialize(int& argc, wxChar **argv);
|
||||
virtual void CleanUp();
|
||||
|
||||
virtual bool Yield(bool onlyIfNeeded = FALSE);
|
||||
|
@@ -82,7 +82,7 @@ protected:
|
||||
|
||||
public:
|
||||
// Implementation
|
||||
virtual bool Initialize(int argc, wxChar **argv);
|
||||
virtual bool Initialize(int& argc, wxChar **argv);
|
||||
virtual void CleanUp();
|
||||
|
||||
// Motif-specific
|
||||
|
@@ -36,7 +36,7 @@ public:
|
||||
virtual ~wxApp();
|
||||
|
||||
// override base class (pure) virtuals
|
||||
virtual bool Initialize(int argc, wxChar **argv);
|
||||
virtual bool Initialize(int& argc, wxChar **argv);
|
||||
virtual void CleanUp();
|
||||
|
||||
virtual int MainLoop();
|
||||
|
@@ -126,7 +126,7 @@ private:
|
||||
public:
|
||||
|
||||
// Implementation
|
||||
virtual bool Initialize(int argc, wxChar **argv);
|
||||
virtual bool Initialize(int& argc, wxChar **argv);
|
||||
virtual void CleanUp(void);
|
||||
|
||||
static bool RegisterWindowClasses(HAB vHab);
|
||||
|
@@ -89,7 +89,7 @@ protected:
|
||||
|
||||
public:
|
||||
// Implementation
|
||||
virtual bool Initialize();
|
||||
virtual bool Initialize(int& argc, wxChar **argv);
|
||||
virtual void CleanUp();
|
||||
|
||||
void DeletePendingObjects();
|
||||
|
111
src/cocoa/app.mm
111
src/cocoa/app.mm
@@ -111,99 +111,6 @@ WX_IMPLEMENT_POSER(wxPoserNSApplication);
|
||||
// functions
|
||||
// ============================================================================
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// wxEntry
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
int WXDLLEXPORT wxEntryStart( int WXUNUSED(argc), char *WXUNUSED(argv)[] )
|
||||
{
|
||||
return wxApp::Initialize();
|
||||
}
|
||||
|
||||
int WXDLLEXPORT wxEntryInitGui()
|
||||
{
|
||||
return wxTheApp->OnInitGui();
|
||||
}
|
||||
|
||||
void WXDLLEXPORT wxEntryCleanup()
|
||||
{
|
||||
wxApp::CleanUp();
|
||||
}
|
||||
|
||||
int wxEntry( int argc, char *argv[])
|
||||
{
|
||||
if (!wxEntryStart(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
wxLogDebug("Creating application");
|
||||
// create the application object or ensure that one already exists
|
||||
if (!wxTheApp)
|
||||
{
|
||||
// The app may have declared a global application object, but we recommend
|
||||
// the IMPLEMENT_APP macro is used instead, which sets an initializer
|
||||
// function for delayed, dynamic app object construction.
|
||||
wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
|
||||
wxT("No initializer - use IMPLEMENT_APP macro.") );
|
||||
|
||||
wxTheApp = (wxApp*) (*wxApp::GetInitializerFunction()) ();
|
||||
}
|
||||
|
||||
wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
|
||||
|
||||
// Mac OS X passes a process serial number command line argument when
|
||||
// the application is launched from the Finder. This argument must be
|
||||
// removed from the command line arguments before being handled by the
|
||||
// application (otherwise applications would need to handle it)
|
||||
|
||||
if (argc > 1) {
|
||||
char theArg[6] = "";
|
||||
strncpy(theArg, argv[1], 5);
|
||||
|
||||
if (strcmp(theArg, "-psn_") == 0) {
|
||||
// assume the argument is always the only one and remove it
|
||||
--argc;
|
||||
}
|
||||
}
|
||||
|
||||
wxTheApp->argc = argc;
|
||||
wxTheApp->argv = argv;
|
||||
|
||||
wxLogDebug("initializing gui");
|
||||
// GUI-specific initialization, such as creating an app context.
|
||||
wxEntryInitGui();
|
||||
|
||||
// Here frames insert themselves automatically
|
||||
// into wxTopLevelWindows by getting created
|
||||
// in OnInit().
|
||||
|
||||
int retValue = 0;
|
||||
|
||||
wxLogDebug("Time to run");
|
||||
retValue = wxTheApp->OnRun();
|
||||
|
||||
wxWindow *topWindow = wxTheApp->GetTopWindow();
|
||||
if ( topWindow )
|
||||
{
|
||||
// Forcibly delete the window.
|
||||
if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
|
||||
topWindow->IsKindOf(CLASSINFO(wxDialog)) )
|
||||
{
|
||||
topWindow->Close(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete topWindow;
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
wxTheApp->OnExit();
|
||||
|
||||
wxEntryCleanup();
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
void wxApp::Exit()
|
||||
{
|
||||
wxApp::CleanUp();
|
||||
@@ -229,11 +136,25 @@ END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxApp static functions
|
||||
// wxApp initialization/cleanup
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxApp::Initialize(int argc, wxChar **argv)
|
||||
bool wxApp::Initialize(int& argc, wxChar **argv)
|
||||
{
|
||||
// Mac OS X passes a process serial number command line argument when
|
||||
// the application is launched from the Finder. This argument must be
|
||||
// removed from the command line arguments before being handled by the
|
||||
// application (otherwise applications would need to handle it)
|
||||
if ( argc > 1 )
|
||||
{
|
||||
static const wxChar *ARG_PSN = _T("-psn_");
|
||||
if ( wxStrncmp(argv[1], ARG_PSN, sizeof(ARG_PSN) - 1) == 0 )
|
||||
{
|
||||
// remove this argument
|
||||
memmove(argv, argv + 1, argc--);
|
||||
}
|
||||
}
|
||||
|
||||
// VZ: apparently this needs to be done a.s.a.p., right? it is done after
|
||||
// wxClassInfo::InitializeClasses() now but usd to be done before, I
|
||||
// hope it's not a problem -- if it is, please let me know, David (if
|
||||
|
@@ -121,7 +121,7 @@ wxAppConsole::~wxAppConsole()
|
||||
// initilization/cleanup
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxAppConsole::Initialize(int argc, wxChar **argv)
|
||||
bool wxAppConsole::Initialize(int& argc, wxChar **argv)
|
||||
{
|
||||
// remember the command line arguments
|
||||
this->argc = argc;
|
||||
|
@@ -73,19 +73,11 @@ wxAppBase::wxAppBase()
|
||||
m_exitOnFrameDelete = Later;
|
||||
}
|
||||
|
||||
bool wxAppBase::Initialize(int argc, wxChar **argv)
|
||||
bool wxAppBase::Initialize(int& argc, wxChar **argv)
|
||||
{
|
||||
if ( !wxAppConsole::Initialize(argc, argv) )
|
||||
return false;
|
||||
|
||||
// for compatibility call the old initialization function too
|
||||
if ( !OnInitGui() )
|
||||
{
|
||||
wxAppConsole::CleanUp();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#if wxUSE_THREADS
|
||||
wxPendingEventsLocker = new wxCriticalSection;
|
||||
#endif
|
||||
|
@@ -87,6 +87,20 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// class to ensure that wxAppBase::CleanUp() is called if our Initialize()
|
||||
// fails
|
||||
class wxCallAppCleanup
|
||||
{
|
||||
public:
|
||||
wxCallAppCleanup(wxApp *app) : m_app(app) { }
|
||||
~wxCallAppCleanup() { if ( m_app ) m_app->CleanUp(); }
|
||||
|
||||
void Dismiss() { m_app = NULL; }
|
||||
|
||||
private:
|
||||
wxApp *m_app;
|
||||
};
|
||||
|
||||
// another tiny class which simply exists to ensure that wxEntryCleanup is
|
||||
// always called
|
||||
class wxCleanupOnExit
|
||||
@@ -180,7 +194,7 @@ static bool DoCommonPostInit()
|
||||
return wxModule::InitializeModules();
|
||||
}
|
||||
|
||||
bool wxEntryStart(int argc, wxChar **argv)
|
||||
bool wxEntryStart(int& argc, wxChar **argv)
|
||||
{
|
||||
// do minimal, always necessary, initialization
|
||||
// --------------------------------------------
|
||||
@@ -229,26 +243,33 @@ bool wxEntryStart(int argc, wxChar **argv)
|
||||
return false;
|
||||
}
|
||||
|
||||
wxCallAppCleanup callAppCleanup(wxTheApp);
|
||||
|
||||
// for compatibility call the old initialization function too
|
||||
if ( !wxTheApp->OnInitGui() )
|
||||
return false;
|
||||
|
||||
|
||||
// common initialization after wxTheApp creation
|
||||
// ---------------------------------------------
|
||||
|
||||
if ( !DoCommonPostInit() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// prevent the smart pointer from destroying its contents
|
||||
app.release();
|
||||
|
||||
// and the cleanup object from doing cleanup
|
||||
callAppCleanup.Dismiss();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
|
||||
// we provide a wxEntryStart() wrapper taking "char *" pointer too
|
||||
bool wxEntryStart(int argc, char **argv)
|
||||
bool wxEntryStart(int& argc, char **argv)
|
||||
{
|
||||
ConvertArgsToUnicode(argc, argv);
|
||||
|
||||
@@ -339,7 +360,7 @@ void wxEntryCleanup()
|
||||
#define wxEntryReal wxEntry
|
||||
#endif // !(__WXMSW__ && wxUSE_ON_FATAL_EXCEPTION)
|
||||
|
||||
int wxEntryReal(int argc, wxChar **argv)
|
||||
int wxEntryReal(int& argc, wxChar **argv)
|
||||
{
|
||||
// library initialization
|
||||
if ( !wxEntryStart(argc, argv) )
|
||||
|
214
src/gtk/app.cpp
214
src/gtk/app.cpp
@@ -676,25 +676,6 @@ bool wxApp::Initialize(int argc, wxChar **argv)
|
||||
if ( !wxAppBase::Initialize(argc, argv) )
|
||||
return false;
|
||||
|
||||
#if wxUSE_INTL
|
||||
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxApp::CleanUp()
|
||||
{
|
||||
wxAppBase::CleanUp();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxEntry
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// NB: argc and argv may be changed here, pass by reference!
|
||||
int wxEntryStart( int& argc, char *argv[] )
|
||||
{
|
||||
#if wxUSE_THREADS
|
||||
// GTK 1.2 up to version 1.2.3 has broken threads
|
||||
if ((gtk_major_version == 1) &&
|
||||
@@ -707,164 +688,87 @@ int wxEntryStart( int& argc, char *argv[] )
|
||||
{
|
||||
g_thread_init(NULL);
|
||||
}
|
||||
#endif
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
gtk_set_locale();
|
||||
|
||||
// We should have the wxUSE_WCHAR_T test on the _outside_
|
||||
#if wxUSE_WCHAR_T
|
||||
#if defined(__WXGTK20__)
|
||||
// gtk+ 2.0 supports Unicode through UTF-8 strings
|
||||
wxConvCurrent = &wxConvUTF8;
|
||||
#else
|
||||
if (!wxOKlibc()) wxConvCurrent = &wxConvLocal;
|
||||
#endif
|
||||
#else
|
||||
if (!wxOKlibc()) wxConvCurrent = (wxMBConv*) NULL;
|
||||
#endif
|
||||
#if defined(__WXGTK20__)
|
||||
// gtk+ 2.0 supports Unicode through UTF-8 strings
|
||||
wxConvCurrent = &wxConvUTF8;
|
||||
#else // GTK 1.x
|
||||
if (!wxOKlibc())
|
||||
wxConvCurrent = &wxConvLocal;
|
||||
#endif
|
||||
#else // !wxUSE_WCHAR_T
|
||||
if (!wxOKlibc())
|
||||
wxConvCurrent = (wxMBConv*) NULL;
|
||||
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
// gtk_init() wants UTF-8, not wchar_t, so convert
|
||||
int i;
|
||||
char *argvGTK = new char *[argc + 1];
|
||||
for ( i = 0; i < argc; i++ )
|
||||
{
|
||||
argvGTK[i] = wxStrdupA(wxConvUTF8.cWX2MB(argv[i]));
|
||||
}
|
||||
|
||||
argvGTK[argc] = NULL;
|
||||
|
||||
int argcGTK = argc;
|
||||
gtk_init( &argcGTK, &argvGTK );
|
||||
|
||||
if ( argcGTK != argc )
|
||||
{
|
||||
// we have to drop the parameters which were consumed by GTK+
|
||||
for ( i = 0; i < argcGTK; i++ )
|
||||
{
|
||||
while ( wxStrcmp(wxConvUTF8.cWX2MB(argv[i]), argvGTK[i]) != 0 )
|
||||
{
|
||||
memmove(argv + i, argv + i + 1, argc - i);
|
||||
}
|
||||
}
|
||||
|
||||
argc = argcGTK;
|
||||
}
|
||||
//else: gtk_init() didn't modify our parameters
|
||||
|
||||
// free our copy
|
||||
for ( i = 0; i < argcGTK; i++ )
|
||||
{
|
||||
free(argvGTK[i]);
|
||||
}
|
||||
|
||||
delete [] argvGTK;
|
||||
#else // !wxUSE_UNICODE
|
||||
// gtk_init() shouldn't actually change argv itself (just its contents) so
|
||||
// it's ok to pass pointer to it
|
||||
gtk_init( &argc, &argv );
|
||||
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
|
||||
|
||||
/* we can not enter threads before gtk_init is done */
|
||||
// we can not enter threads before gtk_init is done
|
||||
gdk_threads_enter();
|
||||
|
||||
wxSetDetectableAutoRepeat( TRUE );
|
||||
|
||||
if (!wxApp::Initialize())
|
||||
{
|
||||
gdk_threads_leave();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wxEntryInitGui()
|
||||
{
|
||||
int retValue = 0;
|
||||
|
||||
if ( !wxTheApp->OnInitGui() )
|
||||
retValue = -1;
|
||||
#if wxUSE_INTL
|
||||
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
|
||||
#endif
|
||||
|
||||
wxGetRootWindow();
|
||||
|
||||
return retValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void wxEntryCleanup()
|
||||
void wxApp::CleanUp()
|
||||
{
|
||||
#if wxUSE_LOG
|
||||
// flush the logged messages if any
|
||||
wxLog *log = wxLog::GetActiveTarget();
|
||||
if (log != NULL && log->HasPendingMessages())
|
||||
log->Flush();
|
||||
|
||||
// continuing to use user defined log target is unsafe from now on because
|
||||
// some resources may be already unavailable, so replace it by something
|
||||
// more safe
|
||||
wxLog *oldlog = wxLog::SetActiveTarget(new wxLogStderr);
|
||||
if ( oldlog )
|
||||
delete oldlog;
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
wxApp::CleanUp();
|
||||
wxAppBase::CleanUp();
|
||||
|
||||
gdk_threads_leave();
|
||||
}
|
||||
|
||||
|
||||
int wxEntry( int argc, char *argv[] )
|
||||
{
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
// This seems to be necessary since there are 'rogue'
|
||||
// objects present at this point (perhaps global objects?)
|
||||
// Setting a checkpoint will ignore them as far as the
|
||||
// memory checking facility is concerned.
|
||||
// Of course you may argue that memory allocated in globals should be
|
||||
// checked, but this is a reasonable compromise.
|
||||
wxDebugContext::SetCheckpoint();
|
||||
#endif
|
||||
int err = wxEntryStart(argc, argv);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (!wxTheApp)
|
||||
{
|
||||
wxCHECK_MSG( wxApp::GetInitializerFunction(), -1,
|
||||
wxT("wxWindows error: No initializer - use IMPLEMENT_APP macro.\n") );
|
||||
|
||||
wxAppInitializerFunction app_ini = wxApp::GetInitializerFunction();
|
||||
|
||||
wxObject *test_app = app_ini();
|
||||
|
||||
wxTheApp = (wxApp*) test_app;
|
||||
}
|
||||
|
||||
wxCHECK_MSG( wxTheApp, -1, wxT("wxWindows error: no application object") );
|
||||
|
||||
wxTheApp->argc = argc;
|
||||
#if wxUSE_UNICODE
|
||||
wxTheApp->argv = new wxChar*[argc+1];
|
||||
int mb_argc = 0;
|
||||
while (mb_argc < argc)
|
||||
{
|
||||
wxTheApp->argv[mb_argc] = wxStrdup(wxConvLibc.cMB2WX(argv[mb_argc]));
|
||||
mb_argc++;
|
||||
}
|
||||
wxTheApp->argv[mb_argc] = (wxChar *)NULL;
|
||||
#else
|
||||
wxTheApp->argv = argv;
|
||||
#endif
|
||||
|
||||
if (wxTheApp->argc > 0)
|
||||
{
|
||||
wxFileName fname( wxTheApp->argv[0] );
|
||||
wxTheApp->SetAppName( fname.GetName() );
|
||||
}
|
||||
|
||||
int retValue;
|
||||
retValue = wxEntryInitGui();
|
||||
|
||||
// Here frames insert themselves automatically into wxTopLevelWindows by
|
||||
// getting created in OnInit().
|
||||
if ( retValue == 0 )
|
||||
{
|
||||
if ( !wxTheApp->OnInit() )
|
||||
retValue = -1;
|
||||
}
|
||||
|
||||
if ( retValue == 0 )
|
||||
{
|
||||
// Delete pending toplevel windows
|
||||
wxTheApp->DeletePendingObjects();
|
||||
|
||||
// When is the app not initialized ?
|
||||
wxTheApp->m_initialized = TRUE;
|
||||
|
||||
if (wxTheApp->Initialized())
|
||||
{
|
||||
wxTheApp->OnRun();
|
||||
|
||||
wxWindow *topWindow = wxTheApp->GetTopWindow();
|
||||
|
||||
// Delete all pending windows if any
|
||||
wxTheApp->DeletePendingObjects();
|
||||
|
||||
// Reset top window
|
||||
if (topWindow)
|
||||
wxTheApp->SetTopWindow( (wxWindow*) NULL );
|
||||
|
||||
retValue = wxTheApp->OnExit();
|
||||
}
|
||||
}
|
||||
|
||||
wxEntryCleanup();
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
|
||||
void wxApp::OnAssert(const wxChar *file, int line, const wxChar* cond, const wxChar *msg)
|
||||
|
214
src/gtk1/app.cpp
214
src/gtk1/app.cpp
@@ -676,25 +676,6 @@ bool wxApp::Initialize(int argc, wxChar **argv)
|
||||
if ( !wxAppBase::Initialize(argc, argv) )
|
||||
return false;
|
||||
|
||||
#if wxUSE_INTL
|
||||
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxApp::CleanUp()
|
||||
{
|
||||
wxAppBase::CleanUp();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxEntry
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// NB: argc and argv may be changed here, pass by reference!
|
||||
int wxEntryStart( int& argc, char *argv[] )
|
||||
{
|
||||
#if wxUSE_THREADS
|
||||
// GTK 1.2 up to version 1.2.3 has broken threads
|
||||
if ((gtk_major_version == 1) &&
|
||||
@@ -707,164 +688,87 @@ int wxEntryStart( int& argc, char *argv[] )
|
||||
{
|
||||
g_thread_init(NULL);
|
||||
}
|
||||
#endif
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
gtk_set_locale();
|
||||
|
||||
// We should have the wxUSE_WCHAR_T test on the _outside_
|
||||
#if wxUSE_WCHAR_T
|
||||
#if defined(__WXGTK20__)
|
||||
// gtk+ 2.0 supports Unicode through UTF-8 strings
|
||||
wxConvCurrent = &wxConvUTF8;
|
||||
#else
|
||||
if (!wxOKlibc()) wxConvCurrent = &wxConvLocal;
|
||||
#endif
|
||||
#else
|
||||
if (!wxOKlibc()) wxConvCurrent = (wxMBConv*) NULL;
|
||||
#endif
|
||||
#if defined(__WXGTK20__)
|
||||
// gtk+ 2.0 supports Unicode through UTF-8 strings
|
||||
wxConvCurrent = &wxConvUTF8;
|
||||
#else // GTK 1.x
|
||||
if (!wxOKlibc())
|
||||
wxConvCurrent = &wxConvLocal;
|
||||
#endif
|
||||
#else // !wxUSE_WCHAR_T
|
||||
if (!wxOKlibc())
|
||||
wxConvCurrent = (wxMBConv*) NULL;
|
||||
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
// gtk_init() wants UTF-8, not wchar_t, so convert
|
||||
int i;
|
||||
char *argvGTK = new char *[argc + 1];
|
||||
for ( i = 0; i < argc; i++ )
|
||||
{
|
||||
argvGTK[i] = wxStrdupA(wxConvUTF8.cWX2MB(argv[i]));
|
||||
}
|
||||
|
||||
argvGTK[argc] = NULL;
|
||||
|
||||
int argcGTK = argc;
|
||||
gtk_init( &argcGTK, &argvGTK );
|
||||
|
||||
if ( argcGTK != argc )
|
||||
{
|
||||
// we have to drop the parameters which were consumed by GTK+
|
||||
for ( i = 0; i < argcGTK; i++ )
|
||||
{
|
||||
while ( wxStrcmp(wxConvUTF8.cWX2MB(argv[i]), argvGTK[i]) != 0 )
|
||||
{
|
||||
memmove(argv + i, argv + i + 1, argc - i);
|
||||
}
|
||||
}
|
||||
|
||||
argc = argcGTK;
|
||||
}
|
||||
//else: gtk_init() didn't modify our parameters
|
||||
|
||||
// free our copy
|
||||
for ( i = 0; i < argcGTK; i++ )
|
||||
{
|
||||
free(argvGTK[i]);
|
||||
}
|
||||
|
||||
delete [] argvGTK;
|
||||
#else // !wxUSE_UNICODE
|
||||
// gtk_init() shouldn't actually change argv itself (just its contents) so
|
||||
// it's ok to pass pointer to it
|
||||
gtk_init( &argc, &argv );
|
||||
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
|
||||
|
||||
/* we can not enter threads before gtk_init is done */
|
||||
// we can not enter threads before gtk_init is done
|
||||
gdk_threads_enter();
|
||||
|
||||
wxSetDetectableAutoRepeat( TRUE );
|
||||
|
||||
if (!wxApp::Initialize())
|
||||
{
|
||||
gdk_threads_leave();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wxEntryInitGui()
|
||||
{
|
||||
int retValue = 0;
|
||||
|
||||
if ( !wxTheApp->OnInitGui() )
|
||||
retValue = -1;
|
||||
#if wxUSE_INTL
|
||||
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
|
||||
#endif
|
||||
|
||||
wxGetRootWindow();
|
||||
|
||||
return retValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void wxEntryCleanup()
|
||||
void wxApp::CleanUp()
|
||||
{
|
||||
#if wxUSE_LOG
|
||||
// flush the logged messages if any
|
||||
wxLog *log = wxLog::GetActiveTarget();
|
||||
if (log != NULL && log->HasPendingMessages())
|
||||
log->Flush();
|
||||
|
||||
// continuing to use user defined log target is unsafe from now on because
|
||||
// some resources may be already unavailable, so replace it by something
|
||||
// more safe
|
||||
wxLog *oldlog = wxLog::SetActiveTarget(new wxLogStderr);
|
||||
if ( oldlog )
|
||||
delete oldlog;
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
wxApp::CleanUp();
|
||||
wxAppBase::CleanUp();
|
||||
|
||||
gdk_threads_leave();
|
||||
}
|
||||
|
||||
|
||||
int wxEntry( int argc, char *argv[] )
|
||||
{
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
// This seems to be necessary since there are 'rogue'
|
||||
// objects present at this point (perhaps global objects?)
|
||||
// Setting a checkpoint will ignore them as far as the
|
||||
// memory checking facility is concerned.
|
||||
// Of course you may argue that memory allocated in globals should be
|
||||
// checked, but this is a reasonable compromise.
|
||||
wxDebugContext::SetCheckpoint();
|
||||
#endif
|
||||
int err = wxEntryStart(argc, argv);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (!wxTheApp)
|
||||
{
|
||||
wxCHECK_MSG( wxApp::GetInitializerFunction(), -1,
|
||||
wxT("wxWindows error: No initializer - use IMPLEMENT_APP macro.\n") );
|
||||
|
||||
wxAppInitializerFunction app_ini = wxApp::GetInitializerFunction();
|
||||
|
||||
wxObject *test_app = app_ini();
|
||||
|
||||
wxTheApp = (wxApp*) test_app;
|
||||
}
|
||||
|
||||
wxCHECK_MSG( wxTheApp, -1, wxT("wxWindows error: no application object") );
|
||||
|
||||
wxTheApp->argc = argc;
|
||||
#if wxUSE_UNICODE
|
||||
wxTheApp->argv = new wxChar*[argc+1];
|
||||
int mb_argc = 0;
|
||||
while (mb_argc < argc)
|
||||
{
|
||||
wxTheApp->argv[mb_argc] = wxStrdup(wxConvLibc.cMB2WX(argv[mb_argc]));
|
||||
mb_argc++;
|
||||
}
|
||||
wxTheApp->argv[mb_argc] = (wxChar *)NULL;
|
||||
#else
|
||||
wxTheApp->argv = argv;
|
||||
#endif
|
||||
|
||||
if (wxTheApp->argc > 0)
|
||||
{
|
||||
wxFileName fname( wxTheApp->argv[0] );
|
||||
wxTheApp->SetAppName( fname.GetName() );
|
||||
}
|
||||
|
||||
int retValue;
|
||||
retValue = wxEntryInitGui();
|
||||
|
||||
// Here frames insert themselves automatically into wxTopLevelWindows by
|
||||
// getting created in OnInit().
|
||||
if ( retValue == 0 )
|
||||
{
|
||||
if ( !wxTheApp->OnInit() )
|
||||
retValue = -1;
|
||||
}
|
||||
|
||||
if ( retValue == 0 )
|
||||
{
|
||||
// Delete pending toplevel windows
|
||||
wxTheApp->DeletePendingObjects();
|
||||
|
||||
// When is the app not initialized ?
|
||||
wxTheApp->m_initialized = TRUE;
|
||||
|
||||
if (wxTheApp->Initialized())
|
||||
{
|
||||
wxTheApp->OnRun();
|
||||
|
||||
wxWindow *topWindow = wxTheApp->GetTopWindow();
|
||||
|
||||
// Delete all pending windows if any
|
||||
wxTheApp->DeletePendingObjects();
|
||||
|
||||
// Reset top window
|
||||
if (topWindow)
|
||||
wxTheApp->SetTopWindow( (wxWindow*) NULL );
|
||||
|
||||
retValue = wxTheApp->OnExit();
|
||||
}
|
||||
}
|
||||
|
||||
wxEntryCleanup();
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
|
||||
void wxApp::OnAssert(const wxChar *file, int line, const wxChar* cond, const wxChar *msg)
|
||||
|
138
src/mac/app.cpp
138
src/mac/app.cpp
@@ -447,7 +447,7 @@ DEFINE_ONE_SHOT_HANDLER_GETTER( wxAppEventHandler )
|
||||
WXIMPORT char std::__throws_bad_alloc ;
|
||||
#endif
|
||||
|
||||
bool wxApp::Initialize(int argc, wxChar **argv)
|
||||
bool wxApp::Initialize(int& argc, wxChar **argv)
|
||||
{
|
||||
int error = 0 ;
|
||||
|
||||
@@ -535,6 +535,20 @@ bool wxApp::Initialize(int argc, wxChar **argv)
|
||||
|
||||
s_macCursorRgn = ::NewRgn() ;
|
||||
|
||||
// Mac OS X passes a process serial number command line argument when
|
||||
// the application is launched from the Finder. This argument must be
|
||||
// removed from the command line arguments before being handled by the
|
||||
// application (otherwise applications would need to handle it)
|
||||
if ( argc > 1 )
|
||||
{
|
||||
static const wxChar *ARG_PSN = _T("-psn_");
|
||||
if ( wxStrncmp(argv[1], ARG_PSN, sizeof(ARG_PSN) - 1) == 0 )
|
||||
{
|
||||
// remove this argument
|
||||
memmove(argv, argv + 1, argc--);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !wxAppBase::Initialize(argc, argv) )
|
||||
return false;
|
||||
|
||||
@@ -634,7 +648,7 @@ void wxApp::CleanUp()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// wxEntry
|
||||
// misc initialization stuff
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// extern variable for shared library resource id
|
||||
@@ -813,126 +827,6 @@ pascal void __wxterminate(void)
|
||||
|
||||
#endif /* WXMAKINGDLL && !__DARWIN__ */
|
||||
|
||||
int WXDLLEXPORT wxEntryStart( int WXUNUSED(argc), char *WXUNUSED(argv)[] )
|
||||
{
|
||||
return wxApp::Initialize();
|
||||
}
|
||||
|
||||
int WXDLLEXPORT wxEntryInitGui()
|
||||
{
|
||||
return wxTheApp->OnInitGui();
|
||||
}
|
||||
|
||||
void WXDLLEXPORT wxEntryCleanup()
|
||||
{
|
||||
wxApp::CleanUp();
|
||||
}
|
||||
|
||||
int wxEntry( int argc, char *argv[] , bool enterLoop )
|
||||
{
|
||||
#ifdef __MWERKS__
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
// This seems to be necessary since there are 'rogue'
|
||||
// objects present at this point (perhaps global objects?)
|
||||
// Setting a checkpoint will ignore them as far as the
|
||||
// memory checking facility is concerned.
|
||||
// Of course you may argue that memory allocated in globals should be
|
||||
// checked, but this is a reasonable compromise.
|
||||
wxDebugContext::SetCheckpoint();
|
||||
#endif
|
||||
#endif
|
||||
if (!wxEntryStart(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
// create the application object or ensure that one already exists
|
||||
if (!wxTheApp)
|
||||
{
|
||||
// The app may have declared a global application object, but we recommend
|
||||
// the IMPLEMENT_APP macro is used instead, which sets an initializer
|
||||
// function for delayed, dynamic app object construction.
|
||||
wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
|
||||
wxT("No initializer - use IMPLEMENT_APP macro.") );
|
||||
|
||||
wxTheApp = (wxApp*) (*wxApp::GetInitializerFunction()) ();
|
||||
}
|
||||
|
||||
wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
|
||||
|
||||
#ifdef __DARWIN__
|
||||
// Mac OS X passes a process serial number command line argument when
|
||||
// the application is launched from the Finder. This argument must be
|
||||
// removed from the command line arguments before being handled by the
|
||||
// application (otherwise applications would need to handle it)
|
||||
|
||||
if (argc > 1) {
|
||||
if (strncmp(argv[1], "-psn_", 5) == 0) {
|
||||
// assume the argument is always the only one and remove it
|
||||
--argc;
|
||||
}
|
||||
}
|
||||
#else
|
||||
argc = 0 ; // currently we don't support files as parameters
|
||||
#endif
|
||||
// we could try to get the open apple events here to adjust argc and argv better
|
||||
|
||||
wxTheApp->argc = argc;
|
||||
#if wxUSE_UNICODE
|
||||
wxTheApp->argv = new wxChar*[argc+1];
|
||||
int mb_argc ;
|
||||
for ( mb_argc = 0; mb_argc < argc; mb_argc++ )
|
||||
{
|
||||
wxTheApp->argv[mb_argc] = wxStrdup(wxConvLocal.cMB2WX(argv[mb_argc]));
|
||||
}
|
||||
wxTheApp->argv[mb_argc] = (wxChar *)NULL;
|
||||
#else
|
||||
wxTheApp->argv = argv;
|
||||
#endif
|
||||
|
||||
// GUI-specific initialization, such as creating an app context.
|
||||
wxEntryInitGui();
|
||||
|
||||
// Here frames insert themselves automatically
|
||||
// into wxTopLevelWindows by getting created
|
||||
// in OnInit().
|
||||
|
||||
int retValue = 0;
|
||||
|
||||
if ( wxTheApp->OnInit() )
|
||||
{
|
||||
if ( enterLoop )
|
||||
{
|
||||
retValue = wxTheApp->OnRun();
|
||||
}
|
||||
else
|
||||
// We want to initialize, but not run or exit immediately.
|
||||
return 1;
|
||||
}
|
||||
//else: app initialization failed, so we skipped OnRun()
|
||||
|
||||
wxWindow *topWindow = wxTheApp->GetTopWindow();
|
||||
if ( topWindow )
|
||||
{
|
||||
// Forcibly delete the window.
|
||||
if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
|
||||
topWindow->IsKindOf(CLASSINFO(wxDialog)) )
|
||||
{
|
||||
topWindow->Close(TRUE);
|
||||
wxTheApp->DeletePendingObjects();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete topWindow;
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
wxTheApp->OnExit();
|
||||
|
||||
wxEntryCleanup();
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
#if TARGET_CARBON
|
||||
|
||||
bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec)
|
||||
|
@@ -447,7 +447,7 @@ DEFINE_ONE_SHOT_HANDLER_GETTER( wxAppEventHandler )
|
||||
WXIMPORT char std::__throws_bad_alloc ;
|
||||
#endif
|
||||
|
||||
bool wxApp::Initialize(int argc, wxChar **argv)
|
||||
bool wxApp::Initialize(int& argc, wxChar **argv)
|
||||
{
|
||||
int error = 0 ;
|
||||
|
||||
@@ -535,6 +535,20 @@ bool wxApp::Initialize(int argc, wxChar **argv)
|
||||
|
||||
s_macCursorRgn = ::NewRgn() ;
|
||||
|
||||
// Mac OS X passes a process serial number command line argument when
|
||||
// the application is launched from the Finder. This argument must be
|
||||
// removed from the command line arguments before being handled by the
|
||||
// application (otherwise applications would need to handle it)
|
||||
if ( argc > 1 )
|
||||
{
|
||||
static const wxChar *ARG_PSN = _T("-psn_");
|
||||
if ( wxStrncmp(argv[1], ARG_PSN, sizeof(ARG_PSN) - 1) == 0 )
|
||||
{
|
||||
// remove this argument
|
||||
memmove(argv, argv + 1, argc--);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !wxAppBase::Initialize(argc, argv) )
|
||||
return false;
|
||||
|
||||
@@ -634,7 +648,7 @@ void wxApp::CleanUp()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// wxEntry
|
||||
// misc initialization stuff
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// extern variable for shared library resource id
|
||||
@@ -813,126 +827,6 @@ pascal void __wxterminate(void)
|
||||
|
||||
#endif /* WXMAKINGDLL && !__DARWIN__ */
|
||||
|
||||
int WXDLLEXPORT wxEntryStart( int WXUNUSED(argc), char *WXUNUSED(argv)[] )
|
||||
{
|
||||
return wxApp::Initialize();
|
||||
}
|
||||
|
||||
int WXDLLEXPORT wxEntryInitGui()
|
||||
{
|
||||
return wxTheApp->OnInitGui();
|
||||
}
|
||||
|
||||
void WXDLLEXPORT wxEntryCleanup()
|
||||
{
|
||||
wxApp::CleanUp();
|
||||
}
|
||||
|
||||
int wxEntry( int argc, char *argv[] , bool enterLoop )
|
||||
{
|
||||
#ifdef __MWERKS__
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
// This seems to be necessary since there are 'rogue'
|
||||
// objects present at this point (perhaps global objects?)
|
||||
// Setting a checkpoint will ignore them as far as the
|
||||
// memory checking facility is concerned.
|
||||
// Of course you may argue that memory allocated in globals should be
|
||||
// checked, but this is a reasonable compromise.
|
||||
wxDebugContext::SetCheckpoint();
|
||||
#endif
|
||||
#endif
|
||||
if (!wxEntryStart(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
// create the application object or ensure that one already exists
|
||||
if (!wxTheApp)
|
||||
{
|
||||
// The app may have declared a global application object, but we recommend
|
||||
// the IMPLEMENT_APP macro is used instead, which sets an initializer
|
||||
// function for delayed, dynamic app object construction.
|
||||
wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
|
||||
wxT("No initializer - use IMPLEMENT_APP macro.") );
|
||||
|
||||
wxTheApp = (wxApp*) (*wxApp::GetInitializerFunction()) ();
|
||||
}
|
||||
|
||||
wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
|
||||
|
||||
#ifdef __DARWIN__
|
||||
// Mac OS X passes a process serial number command line argument when
|
||||
// the application is launched from the Finder. This argument must be
|
||||
// removed from the command line arguments before being handled by the
|
||||
// application (otherwise applications would need to handle it)
|
||||
|
||||
if (argc > 1) {
|
||||
if (strncmp(argv[1], "-psn_", 5) == 0) {
|
||||
// assume the argument is always the only one and remove it
|
||||
--argc;
|
||||
}
|
||||
}
|
||||
#else
|
||||
argc = 0 ; // currently we don't support files as parameters
|
||||
#endif
|
||||
// we could try to get the open apple events here to adjust argc and argv better
|
||||
|
||||
wxTheApp->argc = argc;
|
||||
#if wxUSE_UNICODE
|
||||
wxTheApp->argv = new wxChar*[argc+1];
|
||||
int mb_argc ;
|
||||
for ( mb_argc = 0; mb_argc < argc; mb_argc++ )
|
||||
{
|
||||
wxTheApp->argv[mb_argc] = wxStrdup(wxConvLocal.cMB2WX(argv[mb_argc]));
|
||||
}
|
||||
wxTheApp->argv[mb_argc] = (wxChar *)NULL;
|
||||
#else
|
||||
wxTheApp->argv = argv;
|
||||
#endif
|
||||
|
||||
// GUI-specific initialization, such as creating an app context.
|
||||
wxEntryInitGui();
|
||||
|
||||
// Here frames insert themselves automatically
|
||||
// into wxTopLevelWindows by getting created
|
||||
// in OnInit().
|
||||
|
||||
int retValue = 0;
|
||||
|
||||
if ( wxTheApp->OnInit() )
|
||||
{
|
||||
if ( enterLoop )
|
||||
{
|
||||
retValue = wxTheApp->OnRun();
|
||||
}
|
||||
else
|
||||
// We want to initialize, but not run or exit immediately.
|
||||
return 1;
|
||||
}
|
||||
//else: app initialization failed, so we skipped OnRun()
|
||||
|
||||
wxWindow *topWindow = wxTheApp->GetTopWindow();
|
||||
if ( topWindow )
|
||||
{
|
||||
// Forcibly delete the window.
|
||||
if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
|
||||
topWindow->IsKindOf(CLASSINFO(wxDialog)) )
|
||||
{
|
||||
topWindow->Close(TRUE);
|
||||
wxTheApp->DeletePendingObjects();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete topWindow;
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
wxTheApp->OnExit();
|
||||
|
||||
wxEntryCleanup();
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
#if TARGET_CARBON
|
||||
|
||||
bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec)
|
||||
|
134
src/mgl/app.cpp
134
src/mgl/app.cpp
@@ -383,8 +383,14 @@ void wxApp::Dispatch()
|
||||
wxEventLoop::GetActive()->Dispatch();
|
||||
}
|
||||
|
||||
bool wxApp::Initialize(int argc, wxChar **argv)
|
||||
bool wxApp::Initialize(int& argc, wxChar **argv)
|
||||
{
|
||||
#ifdef __DJGPP__
|
||||
// VS: disable long filenames under DJGPP as the very first thing,
|
||||
// since SciTech MGL doesn't like them much...
|
||||
wxSetEnv(wxT("LFN"), wxT("N"));
|
||||
#endif
|
||||
|
||||
// must do it before calling wxAppBase::Initialize(), because fonts are
|
||||
// needed by stock lists which are created there
|
||||
wxTheFontsManager = new wxFontsManager;
|
||||
@@ -422,129 +428,3 @@ void wxApp::CleanUp()
|
||||
MGL_exit();
|
||||
}
|
||||
|
||||
|
||||
int wxEntryStart(int argc, char *argv[])
|
||||
{
|
||||
return wxApp::Initialize() ? 0 : -1;
|
||||
}
|
||||
|
||||
|
||||
int wxEntryInitGui()
|
||||
{
|
||||
return wxTheApp->OnInitGui() ? 0 : -1;
|
||||
}
|
||||
|
||||
|
||||
void wxEntryCleanup()
|
||||
{
|
||||
wxApp::CleanUp();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int wxEntry(int argc, char *argv[])
|
||||
{
|
||||
#ifdef __DJGPP__
|
||||
// VS: disable long filenames under DJGPP as the very first thing,
|
||||
// since SciTech MGL doesn't like them much...
|
||||
wxSetEnv(wxT("LFN"), wxT("N"));
|
||||
#endif
|
||||
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
// This seems to be necessary since there are 'rogue'
|
||||
// objects present at this point (perhaps global objects?)
|
||||
// Setting a checkpoint will ignore them as far as the
|
||||
// memory checking facility is concerned.
|
||||
// Of course you may argue that memory allocated in globals should be
|
||||
// checked, but this is a reasonable compromise.
|
||||
wxDebugContext::SetCheckpoint();
|
||||
#endif
|
||||
int err = wxEntryStart(argc, argv);
|
||||
if ( err )
|
||||
return err;
|
||||
|
||||
if ( !wxTheApp )
|
||||
{
|
||||
wxCHECK_MSG( wxApp::GetInitializerFunction(), -1,
|
||||
wxT("wxWindows error: No initializer - use IMPLEMENT_APP macro.\n") );
|
||||
|
||||
wxAppInitializerFunction app_ini = wxApp::GetInitializerFunction();
|
||||
|
||||
wxObject *test_app = app_ini();
|
||||
|
||||
wxTheApp = (wxApp*) test_app;
|
||||
}
|
||||
|
||||
wxCHECK_MSG( wxTheApp, -1, wxT("wxWindows error: no application object") );
|
||||
|
||||
wxTheApp->argc = argc;
|
||||
#if wxUSE_UNICODE
|
||||
wxTheApp->argv = new wxChar*[argc+1];
|
||||
int mb_argc = 0;
|
||||
while (mb_argc < argc)
|
||||
{
|
||||
wxTheApp->argv[mb_argc] = wxStrdup(wxConvLibc.cMB2WX(argv[mb_argc]));
|
||||
mb_argc++;
|
||||
}
|
||||
wxTheApp->argv[mb_argc] = (wxChar *)NULL;
|
||||
#else
|
||||
wxTheApp->argv = argv;
|
||||
#endif
|
||||
|
||||
wxString name(wxFileNameFromPath(argv[0]));
|
||||
wxStripExtension(name);
|
||||
wxTheApp->SetAppName(name);
|
||||
|
||||
int retValue;
|
||||
retValue = wxEntryInitGui();
|
||||
|
||||
// Here frames insert themselves automatically into wxTopLevelWindows by
|
||||
// getting created in OnInit().
|
||||
if ( retValue == 0 )
|
||||
{
|
||||
if ( !wxTheApp->OnInit() )
|
||||
retValue = -1;
|
||||
}
|
||||
|
||||
if ( retValue == 0 )
|
||||
{
|
||||
/* delete pending toplevel windows (typically a single
|
||||
dialog) so that, if there isn't any left, we don't
|
||||
call OnRun() */
|
||||
wxTheApp->DeletePendingObjects();
|
||||
|
||||
if ( wxTheApp->Initialized() )
|
||||
{
|
||||
wxTheApp->OnRun();
|
||||
|
||||
wxWindow *topWindow = wxTheApp->GetTopWindow();
|
||||
if ( topWindow )
|
||||
{
|
||||
/* Forcibly delete the window. */
|
||||
if (topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
|
||||
topWindow->IsKindOf(CLASSINFO(wxDialog)) )
|
||||
{
|
||||
topWindow->Close(TRUE);
|
||||
wxTheApp->DeletePendingObjects();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete topWindow;
|
||||
wxTheApp->SetTopWindow((wxWindow*) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#if wxUSE_LOG
|
||||
// flush the logged messages if any
|
||||
wxLog *log = wxLog::GetActiveTarget();
|
||||
if (log != NULL && log->HasPendingMessages())
|
||||
log->Flush();
|
||||
#endif // wxUSE_LOG
|
||||
retValue = wxTheApp->OnExit();
|
||||
}
|
||||
}
|
||||
|
||||
wxEntryCleanup();
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
@@ -86,7 +86,7 @@ END_EVENT_TABLE()
|
||||
}
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
bool wxApp::Initialize(int argc, wxChar **argv)
|
||||
bool wxApp::Initialize(int& argc, wxChar **argv)
|
||||
{
|
||||
if ( !wxAppBase::Initialize(argc, argv) )
|
||||
return false;
|
||||
@@ -112,109 +112,9 @@ void wxApp::Exit()
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxEntry*
|
||||
// wxApp
|
||||
// ============================================================================
|
||||
|
||||
int wxEntryStart( int argc, char* argv[] )
|
||||
{
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
// This seems to be necessary since there are 'rogue'
|
||||
// objects present at this point (perhaps global objects?)
|
||||
// Setting a checkpoint will ignore them as far as the
|
||||
// memory checking facility is concerned.
|
||||
// Of course you may argue that memory allocated in globals should be
|
||||
// checked, but this is a reasonable compromise.
|
||||
wxDebugContext::SetCheckpoint();
|
||||
#endif
|
||||
|
||||
if (!wxApp::Initialize())
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxEntryInitGui()
|
||||
{
|
||||
int retValue = 0;
|
||||
|
||||
// GUI-specific initialization, such as creating an app context.
|
||||
if (!wxTheApp->OnInitGui())
|
||||
retValue = -1;
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
void wxEntryCleanup()
|
||||
{
|
||||
// So dialog boxes aren't used for further messages
|
||||
delete wxLog::SetActiveTarget(new wxLogStderr);
|
||||
|
||||
// flush the logged messages if any
|
||||
wxLog *pLog = wxLog::GetActiveTarget();
|
||||
if ( pLog != NULL && pLog->HasPendingMessages() )
|
||||
pLog->Flush();
|
||||
|
||||
wxApp::CleanUp();
|
||||
}
|
||||
|
||||
int wxEntry( int argc, char *argv[] )
|
||||
{
|
||||
int retValue = 0;
|
||||
|
||||
retValue = wxEntryStart( argc, argv );
|
||||
if (retValue) return retValue;
|
||||
|
||||
if (!wxTheApp)
|
||||
{
|
||||
if (!wxApp::GetInitializerFunction())
|
||||
{
|
||||
printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" );
|
||||
return 0;
|
||||
};
|
||||
|
||||
wxTheApp = (wxApp*) (* wxApp::GetInitializerFunction()) ();
|
||||
};
|
||||
|
||||
if (!wxTheApp)
|
||||
{
|
||||
printf( "wxWindows error: wxTheApp == NULL\n" );
|
||||
return 0;
|
||||
};
|
||||
|
||||
wxTheApp->SetClassName(wxFileNameFromPath(argv[0]));
|
||||
wxTheApp->SetAppName(wxFileNameFromPath(argv[0]));
|
||||
|
||||
wxTheApp->argc = argc;
|
||||
wxTheApp->argv = argv;
|
||||
|
||||
// GUI-specific initialization, such as creating an app context.
|
||||
retValue = wxEntryInitGui();
|
||||
if (retValue) return retValue;
|
||||
|
||||
// Here frames insert themselves automatically into wxTopLevelWindows by
|
||||
// getting created in OnInit().
|
||||
|
||||
if (wxTheApp->OnInit())
|
||||
{
|
||||
if (wxTheApp->Initialized())
|
||||
wxTheApp->OnRun();
|
||||
}
|
||||
|
||||
if (wxTheApp->GetTopWindow())
|
||||
{
|
||||
delete wxTheApp->GetTopWindow();
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
}
|
||||
|
||||
wxTheApp->DeletePendingObjects();
|
||||
|
||||
retValue = wxTheApp->OnExit();
|
||||
|
||||
wxEntryCleanup();
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
wxApp::wxApp()
|
||||
{
|
||||
argc = 0;
|
||||
|
@@ -258,7 +258,7 @@ private:
|
||||
};
|
||||
|
||||
//// Initialize
|
||||
bool wxApp::Initialize(int argc, wxChar **argv)
|
||||
bool wxApp::Initialize(int& argc, wxChar **argv)
|
||||
{
|
||||
if ( !wxAppBase::Initialize(argc, argv) )
|
||||
return false;
|
||||
|
100
src/os2/app.cpp
100
src/os2/app.cpp
@@ -226,7 +226,7 @@ void wxApp::HandleSockets()
|
||||
//
|
||||
// Initialize
|
||||
//
|
||||
bool wxApp::Initialize(int argc, wxChar **argv)
|
||||
bool wxApp::Initialize(int& argc, wxChar **argv)
|
||||
{
|
||||
if ( !wxAppBase::Initialize(argc, argv) )
|
||||
return false;
|
||||
@@ -470,104 +470,6 @@ void wxApp::CleanUp()
|
||||
wxAppBase::CleanUp();
|
||||
} // end of wxApp::CleanUp
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Main wxWindows entry point
|
||||
//----------------------------------------------------------------------
|
||||
int wxEntry(
|
||||
int argc
|
||||
, char* argv[]
|
||||
)
|
||||
{
|
||||
HAB vHab = 0;
|
||||
|
||||
if (!wxApp::Initialize(vHab))
|
||||
return 0;
|
||||
|
||||
//
|
||||
// create the application object or ensure that one already exists
|
||||
//
|
||||
if (!wxTheApp)
|
||||
{
|
||||
// The app may have declared a global application object, but we recommend
|
||||
// the IMPLEMENT_APP macro is used instead, which sets an initializer
|
||||
// function for delayed, dynamic app object construction.
|
||||
wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
|
||||
wxT("No initializer - use IMPLEMENT_APP macro.") );
|
||||
wxTheApp = (*wxApp::GetInitializerFunction()) ();
|
||||
}
|
||||
wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
|
||||
wxTheApp->argc = argc;
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
wxTheApp->argv = new wxChar*[argc+1];
|
||||
|
||||
int nArgc = 0;
|
||||
|
||||
while (nArgc < argc)
|
||||
{
|
||||
wxTheApp->argv[nArgc] = wxStrdup(wxConvLibc.cMB2WX(argv[nArgc]));
|
||||
nArgc++;
|
||||
}
|
||||
wxTheApp->argv[nArgc] = (wxChar *)NULL;
|
||||
#else
|
||||
wxTheApp->argv = argv;
|
||||
#endif
|
||||
|
||||
wxString sName(wxFileNameFromPath(argv[0]));
|
||||
|
||||
wxStripExtension(sName);
|
||||
wxTheApp->SetAppName(sName);
|
||||
|
||||
int nRetValue = 0;
|
||||
|
||||
if (!wxTheApp->OnInitGui())
|
||||
nRetValue = -1;
|
||||
|
||||
if (nRetValue == 0)
|
||||
{
|
||||
if (wxTheApp->OnInit())
|
||||
{
|
||||
wxTheApp->OnRun();
|
||||
}
|
||||
// Normal exit
|
||||
wxWindow* pTopWindow = wxTheApp->GetTopWindow();
|
||||
if (pTopWindow)
|
||||
{
|
||||
// Forcibly delete the window.
|
||||
if (pTopWindow->IsKindOf(CLASSINFO(wxFrame)) ||
|
||||
pTopWindow->IsKindOf(CLASSINFO(wxDialog)) )
|
||||
{
|
||||
pTopWindow->Close(TRUE);
|
||||
wxTheApp->DeletePendingObjects();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pTopWindow;
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // app initialization failed
|
||||
{
|
||||
wxLogLastError(" Gui initialization failed, exitting");
|
||||
}
|
||||
#if wxUSE_CONSOLEDEBUG
|
||||
printf("wxTheApp->OnExit ");
|
||||
fflush(stdout);
|
||||
#endif
|
||||
nRetValue = wxTheApp->OnExit();
|
||||
#if wxUSE_CONSOLEDEBUG
|
||||
printf("wxApp::CleanUp ");
|
||||
fflush(stdout);
|
||||
#endif
|
||||
wxApp::CleanUp();
|
||||
#if wxUSE_CONSOLEDEBUG
|
||||
printf("return %i ", nRetValue);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return(nRetValue);
|
||||
} // end of wxEntry
|
||||
|
||||
bool wxApp::OnInitGui()
|
||||
{
|
||||
ERRORID vError;
|
||||
|
297
src/x11/app.cpp
297
src/x11/app.cpp
@@ -49,8 +49,6 @@ extern wxList wxPendingDelete;
|
||||
wxHashTable *wxWidgetHashTable = NULL;
|
||||
wxHashTable *wxClientWidgetHashTable = NULL;
|
||||
|
||||
// This is set within wxEntryStart -- too early on
|
||||
// to put these in wxTheApp
|
||||
static bool g_showIconic = FALSE;
|
||||
static wxSize g_initialSize = wxDefaultSize;
|
||||
|
||||
@@ -93,10 +91,109 @@ BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
|
||||
EVT_IDLE(wxApp::OnIdle)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
bool wxApp::Initialize(int argc, wxChar **argv)
|
||||
bool wxApp::Initialize(int& argc, wxChar **argv)
|
||||
{
|
||||
if ( !wxAppBase::Initialize(argc, argv) )
|
||||
#if defined(__WXDEBUG__) && !wxUSE_NANOX
|
||||
// install the X error handler
|
||||
gs_pfnXErrorHandler = XSetErrorHandler( wxXErrorHandler );
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
char *displayName = NULL;
|
||||
bool syncDisplay = FALSE;
|
||||
|
||||
int argcOrig = argc;
|
||||
for ( int i = 0; i < argcOrig; i++ )
|
||||
{
|
||||
if (wxStrcmp( argv[i], _T("-display") ) == 0)
|
||||
{
|
||||
if (i < (argc - 1))
|
||||
{
|
||||
argv[i++] = NULL;
|
||||
|
||||
displayName = argv[i];
|
||||
|
||||
argv[i] = NULL;
|
||||
argc -= 2;
|
||||
}
|
||||
}
|
||||
else if (wxStrcmp( argv[i], _T("-geometry") ) == 0)
|
||||
{
|
||||
if (i < (argc - 1))
|
||||
{
|
||||
argv[i++] = NULL;
|
||||
|
||||
int w, h;
|
||||
if (wxSscanf(argv[i], _T("%dx%d"), &w, &h) != 2)
|
||||
{
|
||||
wxLogError( _("Invalid geometry specification '%s'"),
|
||||
wxString::FromAscii(argv[i]).c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_initialSize = wxSize(w, h);
|
||||
}
|
||||
|
||||
argv[i] = NULL;
|
||||
argc -= 2;
|
||||
}
|
||||
}
|
||||
else if (wxStrcmp( argv[i], _T("-sync") ) == 0)
|
||||
{
|
||||
syncDisplay = TRUE;
|
||||
|
||||
argv[i] = NULL;
|
||||
argc--;
|
||||
}
|
||||
else if (wxStrcmp( argv[i], _T("-iconic") ) == 0)
|
||||
{
|
||||
g_showIconic = TRUE;
|
||||
|
||||
argv[i] = NULL;
|
||||
argc--;
|
||||
}
|
||||
}
|
||||
|
||||
if ( argc != argcOrig )
|
||||
{
|
||||
// remove the argumens we consumed
|
||||
for ( int i = 0; i < argc; i++ )
|
||||
{
|
||||
while ( !argv[i] )
|
||||
{
|
||||
memmove(argv + i, argv + i + 1, argcOrig - i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// X11 display stuff
|
||||
Display *xdisplay = XOpenDisplay( displayName );
|
||||
if (!xdisplay)
|
||||
{
|
||||
wxLogError( _("wxWindows could not open display. Exiting.") );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !wxAppBase::Initialize(argc, argv) )
|
||||
{
|
||||
XCloseDisplay(xdisplay);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (syncDisplay)
|
||||
XSynchronize(xdisplay, True);
|
||||
|
||||
ms_display = (WXDisplay*) xdisplay;
|
||||
|
||||
XSelectInput( xdisplay, XDefaultRootWindow(xdisplay), PropertyChangeMask);
|
||||
|
||||
// Misc.
|
||||
wxSetDetectableAutoRepeat( TRUE );
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
// Glib's type system required by Pango
|
||||
g_type_init();
|
||||
#endif
|
||||
|
||||
#if wxUSE_INTL
|
||||
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
|
||||
@@ -118,198 +215,6 @@ void wxApp::CleanUp()
|
||||
wxAppBase::CleanUp();
|
||||
}
|
||||
|
||||
// NB: argc and argv may be changed here, pass by reference!
|
||||
int wxEntryStart( int& argc, char *argv[] )
|
||||
{
|
||||
#ifdef __WXDEBUG__
|
||||
#if !wxUSE_NANOX
|
||||
// install the X error handler
|
||||
gs_pfnXErrorHandler = XSetErrorHandler( wxXErrorHandler );
|
||||
#endif
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
char *displayName = NULL;
|
||||
bool syncDisplay = FALSE;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if (strcmp( argv[i], "-display") == 0)
|
||||
{
|
||||
if (i < (argc - 1))
|
||||
{
|
||||
i ++;
|
||||
displayName = argv[i];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (strcmp( argv[i], "-geometry") == 0)
|
||||
{
|
||||
if (i < (argc - 1))
|
||||
{
|
||||
i ++;
|
||||
int w, h;
|
||||
if (sscanf(argv[i], "%dx%d", &w, &h) != 2)
|
||||
{
|
||||
wxLogError( _("Invalid geometry specification '%s'"), wxString::FromAscii(argv[i]).c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_initialSize = wxSize(w, h);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (strcmp( argv[i], "-sync") == 0)
|
||||
{
|
||||
syncDisplay = TRUE;
|
||||
continue;
|
||||
}
|
||||
else if (strcmp( argv[i], "-iconic") == 0)
|
||||
{
|
||||
g_showIconic = TRUE;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// X11 display stuff
|
||||
Display* xdisplay = XOpenDisplay( displayName );
|
||||
if (!xdisplay)
|
||||
{
|
||||
wxLogError( _("wxWindows could not open display. Exiting.") );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (syncDisplay)
|
||||
XSynchronize(xdisplay, True);
|
||||
|
||||
wxApp::ms_display = (WXDisplay*) xdisplay;
|
||||
|
||||
XSelectInput( xdisplay, XDefaultRootWindow(xdisplay), PropertyChangeMask);
|
||||
|
||||
// Misc.
|
||||
wxSetDetectableAutoRepeat( TRUE );
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
// Glib's type system required by Pango
|
||||
g_type_init();
|
||||
#endif
|
||||
|
||||
if (!wxApp::Initialize())
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxEntryInitGui()
|
||||
{
|
||||
int retValue = 0;
|
||||
|
||||
if ( !wxTheApp->OnInitGui() )
|
||||
retValue = -1;
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
||||
int wxEntry( int argc, char *argv[] )
|
||||
{
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
// This seems to be necessary since there are 'rogue'
|
||||
// objects present at this point (perhaps global objects?)
|
||||
// Setting a checkpoint will ignore them as far as the
|
||||
// memory checking facility is concerned.
|
||||
// Of course you may argue that memory allocated in globals should be
|
||||
// checked, but this is a reasonable compromise.
|
||||
wxDebugContext::SetCheckpoint();
|
||||
#endif
|
||||
int err = wxEntryStart(argc, argv);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (!wxTheApp)
|
||||
{
|
||||
if (!wxApp::GetInitializerFunction())
|
||||
{
|
||||
printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
wxTheApp = (wxApp*) (* wxApp::GetInitializerFunction()) ();
|
||||
}
|
||||
|
||||
if (!wxTheApp)
|
||||
{
|
||||
printf( "wxWindows error: wxTheApp == NULL\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Command line argument stuff
|
||||
wxTheApp->argc = argc;
|
||||
#if wxUSE_UNICODE
|
||||
wxTheApp->argv = new wxChar*[argc+1];
|
||||
int mb_argc = 0;
|
||||
while (mb_argc < argc)
|
||||
{
|
||||
wxString tmp = wxString::FromAscii( argv[mb_argc] );
|
||||
wxTheApp->argv[mb_argc] = wxStrdup( tmp.c_str() );
|
||||
mb_argc++;
|
||||
}
|
||||
wxTheApp->argv[mb_argc] = (wxChar *)NULL;
|
||||
#else
|
||||
wxTheApp->argv = argv;
|
||||
#endif
|
||||
|
||||
if (wxTheApp->argc > 0)
|
||||
{
|
||||
wxFileName fname( wxTheApp->argv[0] );
|
||||
wxTheApp->SetAppName( fname.GetName() );
|
||||
}
|
||||
|
||||
wxTheApp->m_showIconic = g_showIconic;
|
||||
wxTheApp->m_initialSize = g_initialSize;
|
||||
|
||||
int retValue;
|
||||
retValue = wxEntryInitGui();
|
||||
|
||||
// Here frames insert themselves automatically into wxTopLevelWindows by
|
||||
// getting created in OnInit().
|
||||
if ( retValue == 0 )
|
||||
{
|
||||
if ( !wxTheApp->OnInit() )
|
||||
retValue = -1;
|
||||
}
|
||||
|
||||
if ( retValue == 0 )
|
||||
{
|
||||
if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
|
||||
}
|
||||
|
||||
// flush the logged messages if any
|
||||
wxLog *pLog = wxLog::GetActiveTarget();
|
||||
if ( pLog != NULL && pLog->HasPendingMessages() )
|
||||
pLog->Flush();
|
||||
|
||||
delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
|
||||
// for further messages
|
||||
|
||||
if (wxTheApp->GetTopWindow())
|
||||
{
|
||||
delete wxTheApp->GetTopWindow();
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
}
|
||||
|
||||
wxTheApp->DeletePendingObjects();
|
||||
|
||||
wxTheApp->OnExit();
|
||||
|
||||
wxApp::CleanUp();
|
||||
|
||||
return retValue;
|
||||
};
|
||||
|
||||
wxApp::wxApp()
|
||||
{
|
||||
// TODO: parse the command line
|
||||
|
Reference in New Issue
Block a user