Don't use wxApp-dependent functions in headless

When running headless, e.g. from Python script, the wxApp has not be
instantiated, so we cannot use wxConfig.  In this case, we fall back to
the class defaults in ADVANCED_CONFIG()
This commit is contained in:
Seth Hillbrand 2021-06-03 12:30:31 -07:00
parent 4f05262705
commit 4486cdb92e
1 changed files with 5 additions and 0 deletions

View File

@ -26,6 +26,7 @@
#include <config_params.h> #include <config_params.h>
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <wx/app.h>
#include <wx/config.h> #include <wx/config.h>
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/log.h> #include <wx/log.h>
@ -279,6 +280,10 @@ void ADVANCED_CFG::loadFromConfigFile()
{ {
const wxFileName k_advanced = getAdvancedCfgFilename(); const wxFileName k_advanced = getAdvancedCfgFilename();
// If we are running headless, use the class defaults because we cannot instantiate wxConfig
if( !wxTheApp )
return;
if( !k_advanced.FileExists() ) if( !k_advanced.FileExists() )
{ {
wxLogTrace( AdvancedConfigMask, "File does not exist %s", k_advanced.GetFullPath() ); wxLogTrace( AdvancedConfigMask, "File does not exist %s", k_advanced.GetFullPath() );