X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/05e2b077c6187ff4d894e4af58ccd99536c9c584..63ad74ab2d0705a987ea341106f1ca25bfee639e:/src/common/init.cpp?ds=sidebyside diff --git a/src/common/init.cpp b/src/common/init.cpp index ec81ea6ede..4db4aab90d 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -31,6 +31,8 @@ #include "wx/thread.h" #endif +#include "wx/init.h" + #include "wx/ptr_scpd.h" #include "wx/module.h" @@ -109,6 +111,15 @@ public: ~wxCleanupOnExit() { wxEntryCleanup(); } }; +// ---------------------------------------------------------------------------- +// private functions +// ---------------------------------------------------------------------------- + +// suppress warnings about unused variables +static inline void Use(void *) { } + +#define WX_SUPPRESS_UNUSED_WARN(x) Use(&x) + // ---------------------------------------------------------------------------- // initialization data // ---------------------------------------------------------------------------- @@ -139,7 +150,7 @@ static struct InitData // them to Unicode ourselves (this is the case under Unix but not Windows, // for example), we remember the converted argv here because we'll have to // free it when doing cleanup to avoid memory leaks - wchar_t *argv; + wchar_t **argv; #endif // wxUSE_UNICODE } gs_initData; @@ -166,9 +177,15 @@ static void ConvertArgsToUnicode(int argc, char **argv) static void FreeConvertedArgs() { - for ( int mb_argc = 0; mb_argc < wxTheApp->argc; mb_argc++ ) + if ( gs_initData.argv ) { - free(wxTheApp->argv[mb_argc]); + for ( int i = 0; i < gs_initData.argc; i++ ) + { + free(gs_initData.argv[i]); + } + + delete [] gs_initData.argv; + gs_initData.argv = NULL; } } @@ -372,8 +389,10 @@ int wxEntryReal(int& argc, wxChar **argv) // below returns or throws wxCleanupOnExit cleanupOnExit; + WX_SUPPRESS_UNUSED_WARN(cleanupOnExit); + // app initialization - if ( !wxTheApp->OnInit() ) + if ( !wxTheApp->CallOnInit() ) { // don't call OnExit() if OnInit() failed return -1; @@ -409,7 +428,7 @@ int wxEntryReal(int& argc, wxChar **argv) extern unsigned long wxGlobalSEHandler(); -int wxEntry(int argc, wxChar **argv) +int wxEntry(int& argc, wxChar **argv) { __try { @@ -429,7 +448,7 @@ int wxEntry(int argc, wxChar **argv) #if wxUSE_UNICODE // as with wxEntryStart, we provide an ANSI wrapper -int wxEntry(int argc, char **argv) +int wxEntry(int& argc, char **argv) { ConvertArgsToUnicode(argc, argv);