Avoid generating paths on windows with ".." in them

This causes wxwidgets to failover to legacy windows dialogs as windows doesn't know how to handle them being passed to dialogs.
This commit is contained in:
Marek Roszko 2021-06-21 18:03:44 -04:00
parent 6d223931fb
commit aadb62bd42
2 changed files with 23 additions and 3 deletions

View File

@ -154,7 +154,7 @@ wxString PATHS::GetStockDataPath( bool aRespectRunFromBuildDir )
fn.RemoveLastDir();
path = fn.GetPath();
#else
path = Pgm().GetExecutablePath() + wxT( ".." );
path = getWindowsKiCadRoot();
#endif
}
else
@ -162,7 +162,7 @@ wxString PATHS::GetStockDataPath( bool aRespectRunFromBuildDir )
#if defined( __WXMAC__ )
path = GetOSXKicadDataDir();
#elif defined( __WXMSW__ )
path = Pgm().GetExecutablePath() + wxT( "../share/kicad" );
path = getWindowsKiCadRoot() + wxT( "share/kicad" );
#else
path = wxString::FromUTF8Unchecked( KICAD_DATA );
#endif
@ -257,7 +257,7 @@ wxString PATHS::GetDocumentationPath()
#if defined( __WXMAC__ )
path = GetOSXKicadDataDir();
#elif defined( __WXMSW__ )
path = Pgm().GetExecutablePath() + "../share/doc/kicad";
path = getWindowsKiCadRoot() + "share/doc/kicad";
#else
path = wxString::FromUTF8Unchecked( KICAD_DOCS );
#endif
@ -345,3 +345,14 @@ wxString PATHS::GetOSXKicadDataDir()
return ddir.GetPath();
}
#endif
#ifdef __WXWINDOWS__
wxString PATHS::getWindowsKiCadRoot()
{
wxFileName root(Pgm().GetExecutablePath() + "/../");
root.MakeAbsolute();
return root.GetPathWithSep();
}
#endif

View File

@ -145,6 +145,15 @@ private:
* @param aPath Variable to receive the path
*/
static void getUserDocumentPath( wxFileName& aPath );
#ifdef __WXWINDOWS__
/**
* Gets the root of the kicad install on Windows specifically.
* KiCad on Windows has a psuedo posix folder structure contained in it's installed folder
* This retrieves that root for usage in other methods
*/
static wxString getWindowsKiCadRoot();
#endif
};
#endif