X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/62ad77afbdf61cecab324f059f2fc819736332fd..db6634e0d53fce875c78a089f4237a88ae206335:/src/common/init.cpp diff --git a/src/common/init.cpp b/src/common/init.cpp index 86741978f9..bb5693e4a9 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: common/init.cpp +// Name: src/common/init.cpp // Purpose: initialisation for the library // Author: Vadim Zeitlin // Modified by: @@ -20,7 +20,7 @@ #include "wx/wxprec.h" #ifdef __BORLANDC__ - #pragma hdrstop + #pragma hdrstop #endif //__BORLANDC__ #ifndef WX_PRECOMP @@ -29,16 +29,13 @@ #include "wx/log.h" #include "wx/thread.h" #include "wx/intl.h" + #include "wx/module.h" #endif #include "wx/init.h" #include "wx/ptr_scpd.h" -#include "wx/module.h" #include "wx/except.h" -#if wxUSE_FONTMAP -#include "wx/fontmap.h" -#endif #if defined(__WXMSW__) && defined(__WXDEBUG__) #include "wx/msw/msvcrt.h" @@ -179,14 +176,23 @@ static struct InitData static void ConvertArgsToUnicode(int argc, char **argv) { gs_initData.argv = new wchar_t *[argc + 1]; + int wargc = 0; for ( int i = 0; i < argc; i++ ) { wxWCharBuffer buf(wxConvLocal.cMB2WX(argv[i])); - gs_initData.argv[i] = buf ? wxStrdup(buf) : NULL; + if ( !buf ) + { + wxLogWarning(_("Command line argument %d couldn't be converted to Unicode and will be ignored."), + i); + } + else // converted ok + { + gs_initData.argv[wargc++] = wxStrdup(buf); + } } - gs_initData.argc = argc; - gs_initData.argv[argc] = NULL; + gs_initData.argc = wargc; + gs_initData.argv[wargc] = NULL; } static void FreeConvertedArgs() @@ -323,7 +329,7 @@ bool wxEntryStart(int& argc, char **argv) { ConvertArgsToUnicode(argc, argv); - if ( !wxEntryStart(argc, gs_initData.argv) ) + if ( !wxEntryStart(gs_initData.argc, gs_initData.argv) ) { FreeConvertedArgs(); @@ -452,14 +458,7 @@ int wxEntry(int& argc, char **argv) { ConvertArgsToUnicode(argc, argv); -#if wxUSE_FONTMAP - // If we created a font mapper during the above call, - // it will only be the base class, so delete it to allow - // app traits to create mapper. - delete (wxFontMapperBase*) wxFontMapperBase::Set(NULL); -#endif - - return wxEntry(argc, gs_initData.argv); + return wxEntry(gs_initData.argc, gs_initData.argv); } #endif // wxUSE_UNICODE