QLoggingRegistry: remove use of QDir and merge two strings
We don't need to apply QDir::absolutePath() on the diretory that QLibraryInfo::path() returns, because that is already an absolute path (and if it weren't, it wouldn't make a difference anyway). That means we are only doing path concatenation here. For code this low-level, it's better to stick to QString. This commit also rejiggles the string variables so we avoid one of the memory allocations when calling QStandardPaths. Pick-to: 6.9 Change-Id: Ic3405877155a15ac4ac6fffdc92463ae0bff0bd9 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
parent
653c73a83c
commit
e0cdcf66ca
@ -310,18 +310,17 @@ void QLoggingRegistry::initializeRules()
|
||||
er += parser.rules();
|
||||
}
|
||||
|
||||
const QString configFileName = QStringLiteral("qtlogging.ini");
|
||||
const QString configFileName = u"QtProject/qtlogging.ini"_s;
|
||||
QStringView baseConfigFileName = QStringView(configFileName).sliced(strlen("QtProject"));
|
||||
Q_ASSERT(baseConfigFileName.startsWith(u'/'));
|
||||
|
||||
// get rules from Qt data configuration path
|
||||
const QString qtConfigPath
|
||||
= QDir(QLibraryInfo::path(QLibraryInfo::DataPath)).absoluteFilePath(configFileName);
|
||||
qr = loadRulesFromFile(qtConfigPath);
|
||||
qr = loadRulesFromFile(QLibraryInfo::path(QLibraryInfo::DataPath) + baseConfigFileName);
|
||||
|
||||
// get rules from user's/system configuration
|
||||
// locateAll() returns the user's file (most overriding) first
|
||||
const QStringList configPaths =
|
||||
QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation,
|
||||
QString::fromLatin1("QtProject/") + configFileName);
|
||||
QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, configFileName);
|
||||
for (qsizetype i = configPaths.size(); i > 0; --i)
|
||||
cr += loadRulesFromFile(configPaths[i - 1]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user