X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/abca8ebff16ef0e95292a5ceb1aa9fc302552c5d..7b4fee49300c44b2f387c56f4cee9ac3e9b87fb9:/src/common/init.cpp diff --git a/src/common/init.cpp b/src/common/init.cpp index 69dadc09e0..c25c12cd86 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -111,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 // ---------------------------------------------------------------------------- @@ -141,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; @@ -168,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; } } @@ -374,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; @@ -421,8 +438,11 @@ int wxEntry(int& argc, wxChar **argv) { ::ExitProcess(3); // the same exit code as abort() +#if !defined(_MSC_VER) || _MSC_VER < 1300 // this code is unreachable but put it here to suppress warnings + // from some compilers return -1; +#endif } }