From a43c7e58046604796aa69974ea1c5d3e2648c755 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 24 Jan 2025 11:07:58 -0800 Subject: [PATCH] QLibraryInfo: speed up checking if ":/qt/etc/qt.conf" resource exists Go straight for QResource, because this is run very early in Qt's initialization, usually as a result of some debug message, via QLoggingRegistry::initializeRules(). This bypasses the need to create QResourceFileEnginePrivate, QResourceFileEngine, QFileInfoPrivate, and QFileInfo, all of which would end up in this .isValid() call. Additionally, I'm making it query in the C locale, which will also avoid initializing the system & default QLocales. If a resource exists in any language, the C locale query will find it. Task-number: QTBUG-133206 Change-Id: I434b498903d793c12d35fffd3e297bfdbdc1b6fe Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira (cherry picked from commit d59e640c868f3db2d661970f3d34a22013d49053) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit ae2502b4ad3d1215211bf4ed44037a40f52a313d) --- src/corelib/global/qlibraryinfo.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 94f3e60deba..5f6042be29d 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -6,6 +6,7 @@ #include "qstringlist.h" #include "qfile.h" #if QT_CONFIG(settings) +#include "qresource.h" #include "qsettings.h" #endif #include "qlibraryinfo.h" @@ -103,7 +104,7 @@ static std::unique_ptr findConfiguration() return std::make_unique(*qtconfManualPath, QSettings::IniFormat); QString qtconfig = QStringLiteral(":/qt/etc/qt.conf"); - if (QFile::exists(qtconfig)) + if (QResource(qtconfig, QLocale::c()).isValid()) return std::make_unique(qtconfig, QSettings::IniFormat); #ifdef Q_OS_DARWIN CFBundleRef bundleRef = CFBundleGetMainBundle(); -- 2.48.1