Fall back to executable file name in wxApp::GetAppName().

This is especially useful when wxWidgets is used as part of another library
and is not initialized with the real argc/argv containing the application
name.

Closes #16615.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78009 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2014-10-12 20:48:36 +00:00
parent 793187de9d
commit af1191ab99

View File

@ -45,6 +45,7 @@
#include "wx/sysopt.h"
#include "wx/tokenzr.h"
#include "wx/thread.h"
#include "wx/stdpaths.h"
#if wxUSE_EXCEPTIONS
// Do we have a C++ compiler with enough C++11 support for
@ -206,6 +207,16 @@ wxString wxAppConsoleBase::GetAppName() const
// the application name is, by default, the name of its executable file
wxFileName::SplitPath(argv[0], NULL, &name, NULL);
}
#if wxUSE_STDPATHS
else // fall back to the executable file name, if we can determine it
{
const wxString pathExe = wxStandardPaths::Get().GetExecutablePath();
if ( !pathExe.empty() )
{
wxFileName::SplitPath(pathExe, NULL, &name, NULL);
}
}
#endif // wxUSE_STDPATHS
}
return name;
}