Fix an issue with pythons scripts running outside Kicad (Windows specific).
When running a python script is run from a console, outside Kicad, a wxWidgets alert was always show (even in release mode) This is due to calling wxStandardPaths::Get() with no wxApp open( i.e. wxTheApp == O) The fix uses a dummy wxApp in this case.
This commit is contained in:
parent
db19ae226a
commit
aeb479b46f
|
@ -28,6 +28,8 @@
|
|||
#include <shellapi.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
#include <wx/app.h>
|
||||
|
||||
|
||||
void KIPLATFORM::ENV::Init()
|
||||
{
|
||||
|
@ -69,12 +71,28 @@ bool KIPLATFORM::ENV::IsNetworkPath( const wxString& aPath )
|
|||
|
||||
wxString KIPLATFORM::ENV::GetDocumentsPath()
|
||||
{
|
||||
// If called by a python script in stand-alone (outside kicad), wxStandardPaths::Get()
|
||||
// complains about not existing app. so use a dummy app
|
||||
if( wxTheApp == nullptr )
|
||||
{
|
||||
wxApp dummy;
|
||||
return wxStandardPaths::Get().GetDocumentsDir();
|
||||
}
|
||||
|
||||
return wxStandardPaths::Get().GetDocumentsDir();
|
||||
}
|
||||
|
||||
|
||||
wxString KIPLATFORM::ENV::GetUserConfigPath()
|
||||
{
|
||||
// If called by a python script in stand-alone (outside kicad), wxStandardPaths::Get()
|
||||
// complains about not existing app. so use a dummy app
|
||||
if( wxTheApp == nullptr )
|
||||
{
|
||||
wxApp dummy;
|
||||
return wxStandardPaths::Get().GetUserConfigDir();
|
||||
}
|
||||
|
||||
return wxStandardPaths::Get().GetUserConfigDir();
|
||||
}
|
||||
|
||||
|
@ -84,6 +102,17 @@ wxString KIPLATFORM::ENV::GetUserCachePath()
|
|||
// Unfortunately AppData/Local is the closest analog to "Cache" directories of other platforms
|
||||
|
||||
// Make sure we dont include the "appinfo" (appended app name)
|
||||
|
||||
// If called by a python script in stand-alone (outside kicad), wxStandardPaths::Get()
|
||||
// complains about not existing app. so use a dummy app
|
||||
if( wxTheApp == nullptr )
|
||||
{
|
||||
wxApp dummy;
|
||||
wxStandardPaths::Get().UseAppInfo( wxStandardPaths::AppInfo_None );
|
||||
|
||||
return wxStandardPaths::Get().GetUserLocalDataDir();
|
||||
}
|
||||
|
||||
wxStandardPaths::Get().UseAppInfo( wxStandardPaths::AppInfo_None );
|
||||
|
||||
return wxStandardPaths::Get().GetUserLocalDataDir();
|
||||
|
|
Loading…
Reference in New Issue