diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp index e2cc687aa..3b95551e5 100644 --- a/sources/qetapp.cpp +++ b/sources/qetapp.cpp @@ -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; }