1
0
Fork 0

Fix bugs due to incorrect use of SGPath::pathListSep

Before SimGear commit a962c90b30f36575d01162b64471fa77473237a0,
SGPath::pathListSep was a char in static memory that was not necessarily
followed by '\0'. As a consequence, using &SGPath::pathListSep as a
C-style string could result in a string containing the correct separator
*plus* whatever followed in memory until the first null byte...

SimGear commit a962c90b30 changes this situation by making
SGPath::pathListSep an array of two const chars: the path list separator
followed by a '\0'.

This commit simply adapts FlightGear to this change, which fixes a
couple of bugs where the separator was used, mainly unneeded NavCache
rebuilds due to the "apt.dat", "fix.dat" and "nav.dat" properties in the
SQLite database containing the correct paths separated by a possibly
incorrect separator string (there was no alteration of the cache
contents as far as I can tell, since the db property is only used to
check if the lists of apt.dat, fix.dat and nav.dat files have changed).
This commit is contained in:
Florent Rougon 2017-04-15 09:40:44 +02:00
parent 5fa9242d7a
commit 4259b548b0
2 changed files with 3 additions and 3 deletions

View file

@ -2671,7 +2671,7 @@ void Options::showVersion() const
cout << "FG_SCENERY="; cout << "FG_SCENERY=";
PathList scn = globals->get_fg_scenery(); PathList scn = globals->get_fg_scenery();
cout << SGPath::join(scn, &SGPath::pathListSep) << endl; cout << SGPath::join(scn, SGPath::pathListSep) << endl;
cout << "SimGear version: " << SG_STRINGIZE(SIMGEAR_VERSION) << endl; cout << "SimGear version: " << SG_STRINGIZE(SIMGEAR_VERSION) << endl;
#ifndef FG_TESTLIB #ifndef FG_TESTLIB
cout << "OSG version: " << osgGetVersion() << endl; cout << "OSG version: " << osgGetVersion() << endl;

View file

@ -1114,7 +1114,7 @@ bool NavDataCache::NavDataCachePrivate::areDatFilesModified(
const string datTypeStr = const string datTypeStr =
NavDataCache::datTypeStr[datFileType]; NavDataCache::datTypeStr[datFileType];
const string_list cachedFiles = outer->readOrderedStringListProperty( const string_list cachedFiles = outer->readOrderedStringListProperty(
datTypeStr + ".dat files", &SGPath::pathListSep); datTypeStr + ".dat files", SGPath::pathListSep);
const PathList& datFiles = datFilesGroupInfo.paths; const PathList& datFiles = datFilesGroupInfo.paths;
PathList::const_iterator datFilesIt = datFiles.begin(); PathList::const_iterator datFilesIt = datFiles.begin();
string_list::const_iterator cachedFilesIt = cachedFiles.begin(); string_list::const_iterator cachedFilesIt = cachedFiles.begin();
@ -1406,7 +1406,7 @@ void NavDataCache::loadDatFiles(
// Store the list of .dat files we have loaded // Store the list of .dat files we have loaded
writeOrderedStringListProperty(typeStr + ".dat files", datFiles, writeOrderedStringListProperty(typeStr + ".dat files", datFiles,
&SGPath::pathListSep); SGPath::pathListSep);
SG_LOG(SG_NAVCACHE, SG_INFO, SG_LOG(SG_NAVCACHE, SG_INFO,
typeStr + ".dat files load took: " << typeStr + ".dat files load took: " <<
st.elapsedMSec()); st.elapsedMSec());