projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sometimes unused parameter warnings are really worth paying attention to
[wxWidgets.git]
/
src
/
common
/
init.cpp
diff --git
a/src/common/init.cpp
b/src/common/init.cpp
index e699699702c36e7e5b9bd08e748b76882f2cd7e3..ee3847634f00efa2d81bcb31d09d7ec3d8b9f54c 100644
(file)
--- a/
src/common/init.cpp
+++ b/
src/common/init.cpp
@@
-27,12
+27,12
@@
#include "wx/app.h"
#include "wx/filefn.h"
#include "wx/log.h"
#include "wx/app.h"
#include "wx/filefn.h"
#include "wx/log.h"
- #include "wx/thread.h"
#include "wx/intl.h"
#include "wx/module.h"
#endif
#include "wx/init.h"
#include "wx/intl.h"
#include "wx/module.h"
#endif
#include "wx/init.h"
+#include "wx/thread.h"
#include "wx/ptr_scpd.h"
#include "wx/except.h"
#include "wx/ptr_scpd.h"
#include "wx/except.h"
@@
-176,14
+176,27
@@
static struct InitData
static void ConvertArgsToUnicode(int argc, char **argv)
{
gs_initData.argv = new wchar_t *[argc + 1];
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++ )
{
for ( int i = 0; i < argc; i++ )
{
+#ifdef __DARWIN__
+ wxWCharBuffer buf(wxConvFileName->cMB2WX(argv[i]));
+#else
wxWCharBuffer buf(wxConvLocal.cMB2WX(argv[i]));
wxWCharBuffer buf(wxConvLocal.cMB2WX(argv[i]));
- gs_initData.argv[i] = buf ? wxStrdup(buf) : NULL;
+#endif
+ 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 =
w
argc;
+ gs_initData.argv[
w
argc] = NULL;
}
static void FreeConvertedArgs()
}
static void FreeConvertedArgs()
@@
-211,6
+224,9
@@
static void FreeConvertedArgs()
static bool DoCommonPreInit()
{
#if wxUSE_LOG
static bool DoCommonPreInit()
{
#if wxUSE_LOG
+ // Reset logging in case we were cleaned up and are being reinitialized.
+ wxLog::DoCreateOnDemand();
+
// install temporary log sink: we can't use wxLogGui before wxApp is
// constructed and if we use wxLogStderr, all messages during
// initialization simply disappear under Windows
// install temporary log sink: we can't use wxLogGui before wxApp is
// constructed and if we use wxLogStderr, all messages during
// initialization simply disappear under Windows
@@
-282,6
+298,12
@@
bool wxEntryStart(int& argc, wxChar **argv)
return false;
}
return false;
}
+ // remember, possibly modified (e.g. due to removal of toolkit-specific
+ // parameters), command line arguments in member variables
+ app->argc = argc;
+ app->argv = argv;
+
+
wxCallAppCleanup callAppCleanup(app.get());
// for compatibility call the old initialization function too
wxCallAppCleanup callAppCleanup(app.get());
// for compatibility call the old initialization function too
@@
-320,7
+342,7
@@
bool wxEntryStart(int& argc, char **argv)
{
ConvertArgsToUnicode(argc, argv);
{
ConvertArgsToUnicode(argc, argv);
- if ( !wxEntryStart(argc, gs_initData.argv) )
+ if ( !wxEntryStart(
gs_initData.
argc, gs_initData.argv) )
{
FreeConvertedArgs();
{
FreeConvertedArgs();
@@
-382,8
+404,12
@@
void wxEntryCleanup()
{
wxTheApp->CleanUp();
{
wxTheApp->CleanUp();
- delete wxTheApp;
+ // reset the global pointer to it to NULL before destroying it as in
+ // some circumstances this can result in executing the code using
+ // wxTheApp and using half-destroyed object is no good
+ wxAppConsole * const app = wxApp::GetInstance();
wxApp::SetInstance(NULL);
wxApp::SetInstance(NULL);
+ delete app;
}
}
@@
-449,7
+475,7
@@
int wxEntry(int& argc, char **argv)
{
ConvertArgsToUnicode(argc, argv);
{
ConvertArgsToUnicode(argc, argv);
- return wxEntry(argc, gs_initData.argv);
+ return wxEntry(
gs_initData.
argc, gs_initData.argv);
}
#endif // wxUSE_UNICODE
}
#endif // wxUSE_UNICODE