mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-06-20 22:04:13 +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
|
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
||||||
if (config_dir != QString()) return(config_dir);
|
if (config_dir != QString()) return(config_dir);
|
||||||
#endif
|
#endif
|
||||||
QString configdir = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
// C++11 static-local init runs exactly once across all threads — safe to
|
||||||
while (configdir.endsWith('/')) {
|
// call from QtConcurrent background threads (QStandardPaths is not).
|
||||||
configdir.remove(configdir.length()-1, 1);
|
static const QString configdir = []() {
|
||||||
}
|
QString d = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||||
|
while (d.endsWith('/')) d.chop(1);
|
||||||
|
return d;
|
||||||
|
}();
|
||||||
return configdir;
|
return configdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,10 +914,13 @@ QString QETApp::dataDir()
|
|||||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||||
if (data_dir != QString()) return(data_dir);
|
if (data_dir != QString()) return(data_dir);
|
||||||
#endif
|
#endif
|
||||||
QString datadir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
// C++11 static-local init runs exactly once across all threads — safe to
|
||||||
while (datadir.endsWith('/')) {
|
// call from QtConcurrent background threads (QStandardPaths is not).
|
||||||
datadir.remove(datadir.length()-1, 1);
|
static const QString datadir = []() {
|
||||||
}
|
QString d = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
|
while (d.endsWith('/')) d.chop(1);
|
||||||
|
return d;
|
||||||
|
}();
|
||||||
return datadir;
|
return datadir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user