1
0
Fork 0

Correctly initialize an SGPath from the APPDATA environment variable on Windows

This is likely to fix the problem preventing startup on Windows when the
username contains non-ASCII characters (cf.
<https://forum.flightgear.org/viewtopic.php?f=22&t=31320>). Thanks to
Headhunter76 for the useful report and to wkitty42 for doing the liaison
officer. ;-)

I can't actually test this, because I don't have Windows. Windows users
should report whether this works for them.
This commit is contained in:
Florent Rougon 2016-12-28 16:57:26 +01:00
parent bb0869599b
commit d6313e52b5

View file

@ -349,10 +349,18 @@ private:
#ifdef _WIN32
static SGPath platformDefaultDataPath()
{
char *envp = ::getenv( "APPDATA" );
SGPath config( envp );
config.append( "flightgear.org" );
return config;
SGPath appDataPath = SGPath::fromEnv("APPDATA");
if (appDataPath.isNull()) {
flightgear::fatalMessageBox(
"FlightGear", "Unable to get the value of APPDATA.",
"FlightGear is unable to retrieve the value of the APPDATA environment "
"variable. This is quite unexpected on Windows platforms, and FlightGear "
"can't continue its execution without this value, sorry.");
exit(EXIT_FAILURE);
}
return appDataPath / "flightgear.org";
}
#elif defined(SG_MAC)