mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-06-20 13:44:12 +02:00
Merge pull request #514 from ispyisail/fix/thread-safe-datadir-configdir
Thank you @ispyisail
This commit is contained in:
+14
-8
@@ -887,10 +887,13 @@ QString QETApp::configDir()
|
||||
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
if (config_dir != QString()) return(config_dir);
|
||||
#endif
|
||||
QString configdir = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||
while (configdir.endsWith('/')) {
|
||||
configdir.remove(configdir.length()-1, 1);
|
||||
}
|
||||
// C++11 static-local init runs exactly once across all threads — safe to
|
||||
// call from QtConcurrent background threads (QStandardPaths is not).
|
||||
static const QString configdir = []() {
|
||||
QString d = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||
while (d.endsWith('/')) d.chop(1);
|
||||
return d;
|
||||
}();
|
||||
return configdir;
|
||||
}
|
||||
|
||||
@@ -911,10 +914,13 @@ QString QETApp::dataDir()
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
if (data_dir != QString()) return(data_dir);
|
||||
#endif
|
||||
QString datadir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
while (datadir.endsWith('/')) {
|
||||
datadir.remove(datadir.length()-1, 1);
|
||||
}
|
||||
// C++11 static-local init runs exactly once across all threads — safe to
|
||||
// call from QtConcurrent background threads (QStandardPaths is not).
|
||||
static const QString datadir = []() {
|
||||
QString d = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
while (d.endsWith('/')) d.chop(1);
|
||||
return d;
|
||||
}();
|
||||
return datadir;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user