From b65a76a8a438d099da63f62e2b8de7a764ba950c Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 16 Feb 2024 19:46:56 +0100 Subject: PCRE2: upgrade to 10.43 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apart from some source code reshuffling, 10.43's JIT has dropped its support for ARMv5. [ChangeLog][Third-Party Code] PCRE2 was updated to version 10.43. Change-Id: I7909f0a9358f38282f5eaeacd2eb10529b47e63c Reviewed-by: Volker Hilsheimer Reviewed-by: Kai Köhne (cherry picked from commit 909d881e7539bc77ab79650782ae91372fb4ee83) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 18d15404cbbbb87547e7a99623650d5ed69898c9) (cherry picked from commit 179164ef1400dc18b6a1cb2a5bf6d22bd670b5b3) --- src/corelib/text/qregularexpression.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp index 5a5cdd51699..1ed8c57db3a 100644 --- a/src/corelib/text/qregularexpression.cpp +++ b/src/corelib/text/qregularexpression.cpp @@ -3060,7 +3060,8 @@ static const char *pcreCompileErrorCodes[] = QT_TRANSLATE_NOOP("QRegularExpression", "heap limit exceeded"), QT_TRANSLATE_NOOP("QRegularExpression", "invalid syntax"), QT_TRANSLATE_NOOP("QRegularExpression", "internal error - duplicate substitution match"), - QT_TRANSLATE_NOOP("QRegularExpression", "PCRE2_MATCH_INVALID_UTF is not supported for DFA matching") + QT_TRANSLATE_NOOP("QRegularExpression", "PCRE2_MATCH_INVALID_UTF is not supported for DFA matching"), + QT_TRANSLATE_NOOP("QRegularExpression", "INTERNAL ERROR: invalid substring offset") }; #endif // #if 0 -- cgit v1.2.3 From 7a8d46d6302a2f49fc3278817c9a9ef8c9c27d92 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 8 Feb 2024 14:25:24 +0100 Subject: QLoggingRegistry: further defend against non-NUL-terminated strings Various functions in QLoggingRegistry took QByteArrayView, but they continued to assume that the data was NUL-terminated (converting back to const char* by calling data()). Make sure only NUL-terminated strings are passed by taking in the tranditional way, as const char*. Keep QByteArrayView when storing in the map as key, to avoid comparing just pointer values (as opposed to the string content). Amends 806545fcc8d6b3b96a5191a00a31e9a39837189c. Change-Id: I232167d4c91070369e770c41d3ea53bd2406a03f Reviewed-by: Thiago Macieira (cherry picked from commit 6b59ff573028eabba42ca63ce50ce05fa160ecaf) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 1bba8b894a36230d2bc577c6596e9bf82de1c432) (cherry picked from commit ee8cb743d32b078dae3f746ac5d075a158eaf01e) --- src/corelib/io/qloggingregistry.cpp | 6 +++--- src/corelib/io/qloggingregistry_p.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index cfd3da1ad63..a0fcb67651e 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -347,8 +347,8 @@ void QLoggingRegistry::unregisterCategory(QLoggingCategory *cat) for enabling debugging by default for category \a categoryName. The category name must start with "qt." */ -void QLoggingRegistry::registerEnvironmentOverrideForCategory(QByteArrayView categoryName, - QByteArrayView environment) +void QLoggingRegistry::registerEnvironmentOverrideForCategory(const char *categoryName, + const char *environment) { qtCategoryEnvironmentOverrides.insert(categoryName, environment); } @@ -442,7 +442,7 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat) if (it == reg->qtCategoryEnvironmentOverrides.end()) debug = false; else - debug = qEnvironmentVariableIntValue(it.value().data()); + debug = qEnvironmentVariableIntValue(it.value()); } } diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index ca4d2d9a15f..7f66337dfeb 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -97,7 +97,7 @@ public: #ifndef QT_BUILD_INTERNAL Q_CORE_EXPORT // always export from QtCore #endif - void registerEnvironmentOverrideForCategory(QByteArrayView categoryName, QByteArrayView environment); + void registerEnvironmentOverrideForCategory(const char *categoryName, const char *environment); void setApiRules(const QString &content); @@ -127,7 +127,7 @@ private: QList ruleSets[NumRuleSets]; QHash categories; QLoggingCategory::CategoryFilter categoryFilter; - QMap qtCategoryEnvironmentOverrides; + QMap qtCategoryEnvironmentOverrides; friend class ::tst_QLoggingRegistry; }; @@ -140,12 +140,12 @@ public: {} private: - static const char *registerOverride(QByteArrayView categoryName, QByteArrayView environment) + static const char *registerOverride(const char *categoryName, const char *environment) { QLoggingRegistry *c = QLoggingRegistry::instance(); if (c) c->registerEnvironmentOverrideForCategory(categoryName, environment); - return categoryName.data(); + return categoryName; } }; -- cgit v1.2.3 From afd176500b012909e80260fc14256f395c52ba07 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Mon, 19 Feb 2024 09:19:04 +0000 Subject: Revert "Revert "Add the support of the qt_import_plugins functionality to androiddeployqt"" This reverts commit 219a0aabc118916c3be16e647a2a1411805cb15a. Reason for revert: Since the respective fixes are merged we may revert this back. Task-number: QAA-2266 Change-Id: I949ac9adbe268be65bf4fd402d1d6322f134146b Reviewed-by: Alexandru Croitor (cherry picked from commit 116776a25ea462f6ab8475b9128337867ff96e25) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/Qt6AndroidMacros.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake index 9a8d02165f2..c0319fbdb3c 100644 --- a/src/corelib/Qt6AndroidMacros.cmake +++ b/src/corelib/Qt6AndroidMacros.cmake @@ -236,6 +236,10 @@ function(qt6_android_generate_deployment_settings target) _qt_internal_add_android_deployment_property(file_contents "android-no-deploy-qt-libs" ${target} "QT_ANDROID_NO_DEPLOY_QT_LIBS") + __qt_internal_collect_plugin_targets_from_dependencies("${target}" plugin_targets) + __qt_internal_collect_plugin_library_files("${target}" "${plugin_targets}" plugin_targets) + string(APPEND file_contents " \"android-deploy-plugins\":\"${plugin_targets}\",\n") + # App binary string(APPEND file_contents " \"application-binary\": \"${target_output_name}\",\n") @@ -303,7 +307,7 @@ function(qt6_android_generate_deployment_settings target) # content end string(APPEND file_contents "}\n") - file(GENERATE OUTPUT ${deploy_file} CONTENT ${file_contents}) + file(GENERATE OUTPUT ${deploy_file} CONTENT "${file_contents}") set_target_properties(${target} PROPERTIES -- cgit v1.2.3 From 31176692bb0e436387893115b54e0754fdb4783a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 16 Feb 2024 10:57:03 +0100 Subject: QMime: remove unused qmap.h includes These TUs never seem to never have used QMap, QMultiMap or QVariantMap, so remove the superfluous includes. Amends ffa5820fa3bf8b28675129919d748373d6c77827. Change-Id: I3381fced294d7b99d3553d0efde38f20f01e4e97 Reviewed-by: David Faure (cherry picked from commit 7285fea9f3ba0824dbc12bb9de463f8e6ebd3c2e) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit b2b3a08dbd8b7887e4a8364e8ecc4a3cb0c0c3ec) (cherry picked from commit 8af724ce1566c84a88e3babe030c884829fc28a8) --- src/corelib/mimetypes/qmimedatabase.cpp | 1 - src/corelib/mimetypes/qmimemagicrule.cpp | 1 - 2 files changed, 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index 3ac9fe8ce03..a72b7e6bd4d 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -12,7 +12,6 @@ #include -#include #include #include #include diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp index d71cf0868a2..6eaaaa7c0fe 100644 --- a/src/corelib/mimetypes/qmimemagicrule.cpp +++ b/src/corelib/mimetypes/qmimemagicrule.cpp @@ -8,7 +8,6 @@ #include "qmimetypeparser_p.h" #include -#include #include #include -- cgit v1.2.3 From 3a6031a99f4b3e18ca69a37a3c6381b0bcfeb6e4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 9 Feb 2024 17:25:18 +0100 Subject: QTzTimeZoneCache: make findEntry() static It doesn't need access to the members, so making it static both saves the implicit this pointer, and communicates to the reader that this is function doesn't access other QTzTimeZoneCache members. In particular, it proves that it doesn't really need to be called with m_mutex locked, cf. QTBUG-122138. Task-number: QTBUG-122138 Change-Id: I28c99be8d066c1647aaf7aa256b6400a6dd92955 Reviewed-by: Thiago Macieira (cherry picked from commit 7862453ba9cbcb601b9aad59dd821ae49661de4a) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 3265e2467d5312d16a2b30d66770abad2af6705a) (cherry picked from commit c4b0d1bd6d281f0c166d8ef3fa0cb69b9aed9cdc) --- src/corelib/time/qtimezoneprivate_tz.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp index 0740f4dfe96..a520c707552 100644 --- a/src/corelib/time/qtimezoneprivate_tz.cpp +++ b/src/corelib/time/qtimezoneprivate_tz.cpp @@ -772,7 +772,7 @@ public: QTzTimeZoneCacheEntry fetchEntry(const QByteArray &ianaId); private: - QTzTimeZoneCacheEntry findEntry(const QByteArray &ianaId); + static QTzTimeZoneCacheEntry findEntry(const QByteArray &ianaId); QCache m_cache; QMutex m_mutex; }; -- cgit v1.2.3 From 1575ffbfdbb73a37ef1ce24b356a02a4b8bbd0c3 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Tue, 6 Feb 2024 13:40:25 +0800 Subject: corelib: settings - make qsettings.cpp unity buildable Both qsettings.cpp and qjsonparser.cpp defined Space in the global namespace. Hiding it in one of them in an implementation namespace resolves the name clash. Change-Id: I8dd1244f80d87f3908597ed82c8e41b49b7b916c Reviewed-by: Marc Mutz (cherry picked from commit 4ff65f0e5615b1132ec13c6eeba3647162d8dd0f) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit a4c158effe328dede9ddbe35bc59449a6d9cb55a) (cherry picked from commit d2e685e0b53fb8cd3d05a67b3512ba9eb6aa82d8) --- src/corelib/CMakeLists.txt | 1 - src/corelib/io/qsettings.cpp | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index f3649f7f602..2df45916269 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -316,7 +316,6 @@ qt_internal_add_module(Core text/qstringconverter.cpp # enum Data tools/qcryptographichash.cpp # KeccakNISTInterface/Final io/qdebug.cpp # undef qDebug - io/qsettings.cpp # Space (also in qjsonparser.cpp) NO_PCH_SOURCES compat/removed_api.cpp global/qsimd.cpp diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 3ca57aefcff..52647f6af26 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1494,6 +1494,8 @@ void QConfFileSettingsPrivate::syncConfFile(QConfFile *confFile) } } +namespace SettingsImpl { + enum { Space = 0x1, Special = 0x2 }; static const char charTraits[256] = @@ -1520,10 +1522,15 @@ static const char charTraits[256] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +} // namespace SettingsImpl + +using SettingsImpl::charTraits; + bool QConfFileSettingsPrivate::readIniLine(QByteArrayView data, qsizetype &dataPos, qsizetype &lineStart, qsizetype &lineLen, qsizetype &equalsPos) { + using namespace SettingsImpl; qsizetype dataLen = data.size(); bool inQuotes = false; -- cgit v1.2.3 From 1df2df58ba40cbe4a030f898335608b18c94f64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 13 Feb 2024 15:09:55 +0100 Subject: QLocal8Bit::convertToUnicode[win]: Fix order of growth and saturate The order was wrong so we could have ended up saturating a 0 before we grew to 1. Since this has never been in a release it is of no concern, and it was already an edge-case anyway. Amends 1090d5dd4ae5be898d4566314eda43b0283709d9 Change-Id: I4b70f9018c3049697495a58313af148f8366c8bb Reviewed-by: Marc Mutz Reviewed-by: Edward Welbourne (cherry picked from commit 0d6b64bec6b555a6e534538a38d40259017f0de3) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit fa90e1a8123966c494ad7b73e6b03c791916a452) (cherry picked from commit 14b753c1c888d349c4c74af3cf2b83422eb4cb47) --- src/corelib/text/qstringconverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index 47bd98eea97..ec87f0264e2 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -1365,10 +1365,10 @@ QString QLocal8Bit::convertToUnicode_sys(QByteArrayView in, quint32 codePage, // encounter an error int nextIn = qt_saturate(mblen); while (mblen > 0) { - const int nextOut = qt_saturate(outlen); std::tie(out, outlen) = growOut(1); // Need space for at least one character if (!out) return {}; + const int nextOut = qt_saturate(outlen); len = MultiByteToWideChar(codePage, MB_ERR_INVALID_CHARS, mb, nextIn, out, nextOut); if (len) { mb += nextIn; -- cgit v1.2.3 From 3f222b6ddcd701dd72bf7aa21eb4c584d43d61f3 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Tue, 27 Feb 2024 17:57:05 +0100 Subject: Fix the qtpath issue with lto enabled Move qtconfManualPath pointer to the unnamed namespace, so it's never exported. Add the static setQtconfManualPath method that sets the pointer at runtime. Fixes: QTBUG-122739 Change-Id: Icfc631f9680ad5f484920b0fdf3e408b7657c108 Reviewed-by: Joerg Bornemann Reviewed-by: Thiago Macieira (cherry picked from commit bdb2f20154c1fa1f0962a46a22afdee453a2db1e) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit a405320544a190fac3aaa0bfe8e842e4019e5386) (cherry picked from commit dc118ad13f28b0721b1118fdbe43a3f5c33ac84a) --- src/corelib/global/qlibraryinfo.cpp | 15 +++++++++++---- src/corelib/global/qlibraryinfo_p.h | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index fc23078381a..83e131d5912 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -87,10 +87,19 @@ void QLibrarySettings::load() } } +namespace { +const QString *qtconfManualPath = nullptr; +} + +void QLibraryInfoPrivate::setQtconfManualPath(const QString *path) +{ + qtconfManualPath = path; +} + static QSettings *findConfiguration() { - if (QLibraryInfoPrivate::qtconfManualPath) - return new QSettings(*QLibraryInfoPrivate::qtconfManualPath, QSettings::IniFormat); + if (qtconfManualPath) + return new QSettings(*qtconfManualPath, QSettings::IniFormat); QString qtconfig = QStringLiteral(":/qt/etc/qt.conf"); if (QFile::exists(qtconfig)) @@ -122,8 +131,6 @@ static QSettings *findConfiguration() return nullptr; //no luck } -const QString *QLibraryInfoPrivate::qtconfManualPath = nullptr; - QSettings *QLibraryInfoPrivate::configuration() { QLibrarySettings *ls = qt_library_settings(); diff --git a/src/corelib/global/qlibraryinfo_p.h b/src/corelib/global/qlibraryinfo_p.h index de1964509ca..9eac5959542 100644 --- a/src/corelib/global/qlibraryinfo_p.h +++ b/src/corelib/global/qlibraryinfo_p.h @@ -32,7 +32,7 @@ public: #if QT_CONFIG(settings) static QSettings *configuration(); static void reload(); - static const QString *qtconfManualPath; + static void setQtconfManualPath(const QString *qtconfManualPath); #endif struct LocationInfo -- cgit v1.2.3 From 99764828112385915acacd2f92190f61091bd2a0 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Thu, 29 Feb 2024 12:10:57 +0100 Subject: Disable depfile support for the external projects when building for Android androiddeployqt rules that support depfiles cause creation of rules that interfere each other and cause the test build flakiness in CI. This disables depfile support for ABI-specific external project until the rootcase is found. Task-number: QTBUG-122838 Change-Id: I12e85f43494331c943c9b516d9494593facf9180 Reviewed-by: Assam Boudjelthia (cherry picked from commit 356b0aee0e93c9fc51e79faa8d6904bf4d5a6c27) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 58b9d558ddd72656b2e7204e7021758efd169c91) (cherry picked from commit b62c56578cabc387cdc98704332d74a45112cc60) --- src/corelib/Qt6AndroidMacros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake index c0319fbdb3c..83b82f3e4ba 100644 --- a/src/corelib/Qt6AndroidMacros.cmake +++ b/src/corelib/Qt6AndroidMacros.cmake @@ -558,7 +558,7 @@ function(qt6_android_add_apk_target target) "$" "${androiddeployqt_output_path}/${target_file_copy_relative_path}" ) - if(has_depfile_support) + if(has_depfile_support AND FALSE) # TODO: It breaks multi-abi builds. See QTBUG-122838 set(deploy_android_deps_dir "${apk_final_dir}/${target}_deploy_android") set(timestamp_file "${deploy_android_deps_dir}/timestamp") set(dep_file "${deploy_android_deps_dir}/${target}.d") -- cgit v1.2.3 From 71f367859e209c3057f2dd4fab82593789533f1b Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 15 Mar 2023 17:19:14 +0100 Subject: Recognize POSIX rules as valid timezone IDs for the TZ backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The constructor, via findEntry(), does allow a POSIX rule as a valid ID, so reflect that in the implementation of isTimeZoneIdAvailable(), even though we can't sensibly enumerate all possible POSIX rules in availableTimeZoneIds(). Retroactively picked to 6.5 to enable the TZ backend's constructor to check for availability before creating a bogus cache entry. Change-Id: I7fd21d23ce8ce40c7f423b02e18d2e8df30fb952 Reviewed-by: Thiago Macieira (cherry picked from commit 41c561ddde6210651c60c0789d592f79d7b3e4d5) Reviewed-by: Mårten Nordheim --- src/corelib/time/qtimezoneprivate_tz.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp index a520c707552..8e6e153166b 100644 --- a/src/corelib/time/qtimezoneprivate_tz.cpp +++ b/src/corelib/time/qtimezoneprivate_tz.cpp @@ -578,7 +578,12 @@ PosixZone PosixZone::parse(const char *&pos, const char *end) return {std::move(name), offset}; } -static auto validatePosixRule(const QByteArray &posixRule) +/* Parse and check a POSIX rule. + + By default a simple zone abbreviation with no offset information is accepted. + Set \a requireOffset to \c true to require that there be offset data present. +*/ +static auto validatePosixRule(const QByteArray &posixRule, bool requireOffset = false) { // Format is described here: // http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html @@ -590,15 +595,19 @@ static auto validatePosixRule(const QByteArray &posixRule) return fail; const char *begin = zoneinfo.begin(); - - // Updates begin to point after the name and offset it parses: - if (PosixZone::parse(begin, zoneinfo.end()).name.isEmpty()) - return fail; + { + // Updates begin to point after the name and offset it parses: + const auto posix = PosixZone::parse(begin, zoneinfo.end()); + if (posix.name.isEmpty()) + return fail; + if (requireOffset && !posix.hasValidOffset()) + return fail; + } if (good.hasDst) { if (begin >= zoneinfo.end()) return fail; - // Expect a second name and offset after the first: + // Expect a second name (and optional offset) after the first: if (PosixZone::parse(begin, zoneinfo.end()).name.isEmpty()) return fail; } @@ -1239,7 +1248,11 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecs bool QTzTimeZonePrivate::isTimeZoneIdAvailable(const QByteArray &ianaId) const { - return tzZones->contains(ianaId); + // Allow a POSIX rule as long as it has offset data. (This needs to reject a + // plain abbreviation, without offset, since claiming to support such zones + // would prevent the custom QTimeZone constructor from accepting such a + // name, as it doesn't want a custom zone to over-ride a "real" one.) + return tzZones->contains(ianaId) || validatePosixRule(ianaId, true).isValid; } QList QTzTimeZonePrivate::availableTimeZoneIds() const -- cgit v1.2.3 From 078111d80136ef7b7802eb060cfffe46dd184705 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 9 Feb 2024 13:56:52 +0100 Subject: Also check available in TZ timezone's constructor Follow up to commit 00d9a9a9b59650b8e297f91dcc600c377da5bceb - as commented in the QTZ constructor, one of the reasons for the prior "is available" check was to avoid creating TZ cache entries for it; so have the TZ backend also (like ICU) overtly check for availability before trying to find data for the given ID. This duplicates work done later in the constructor, which can perhaps be optimised out later, but is no worse than where we were before the commit mentioned above. Task-number: QTBUG-121807 Change-Id: Ie0571df2de2bf0a3f4ee767184e58b378e8cb05a Reviewed-by: Thiago Macieira (cherry picked from commit ec9ca7ac43cfebc74afc03de338f81a879354b2a) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit a3a2d3df20a61836c41b9f115b2a8244d4381519) (cherry picked from commit 9f304ee3e84a1bcc875013f5753611eff69bc763) Reviewed-by: Qt CI Bot --- src/corelib/time/qtimezoneprivate_tz.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp index 8e6e153166b..46900c5d3cb 100644 --- a/src/corelib/time/qtimezoneprivate_tz.cpp +++ b/src/corelib/time/qtimezoneprivate_tz.cpp @@ -986,6 +986,8 @@ QTzTimeZoneCacheEntry QTzTimeZoneCache::fetchEntry(const QByteArray &ianaId) // Create a named time zone QTzTimeZonePrivate::QTzTimeZonePrivate(const QByteArray &ianaId) { + if (!isTimeZoneIdAvailable(ianaId)) // Avoid pointlessly creating cache entries + return; static QTzTimeZoneCache tzCache; auto entry = tzCache.fetchEntry(ianaId); if (entry.m_tranTimes.isEmpty() && entry.m_posixRule.isEmpty()) -- cgit v1.2.3 From 4a252aebba32ffdd4ef68006e4349e40e6376c11 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 7 Mar 2024 21:49:48 +0100 Subject: QGlobalStatic: suppress -Wtsan warning QGS employs a call to std::atomic_thread_fence. Unfortunately TSAN does not support it, and GCC >= 11 raises a warning. This breaks the build when building under -Werror. Suppress the warning using the usual pragmas. There's a catch: qglobalstatic.h is built into a PCH, and GCC <= 13 will still generate a warning because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431 . Change-Id: I770f39b7563b66f483851444cd580bcafc5f288a Reviewed-by: Thiago Macieira (cherry picked from commit 143bcbb96f512d8e4014f0abba99f8e7a8729499) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 21c3f17eaa9aa4ad56c8f74e3f67c52420a3fbc7) (cherry picked from commit 0c661c15284a22734f8956167b291a9b7f31c957) --- src/corelib/global/qglobalstatic.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 27a5a985314..18834473c79 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -41,8 +41,16 @@ template union Holder ~Holder() { + // TSAN does not support atomic_thread_fence and GCC complains: + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97868 + // https://github.com/google/sanitizers/issues/1352 +QT_WARNING_PUSH +#if defined(Q_CC_GNU_ONLY) && Q_CC_GNU >= 1100 +QT_WARNING_DISABLE_GCC("-Wtsan") +#endif // import changes to *pointer() by other threads before running ~PlainType(): std::atomic_thread_fence(std::memory_order_acquire); +QT_WARNING_POP pointer()->~PlainType(); guard.storeRelease(QtGlobalStatic::Destroyed); } -- cgit v1.2.3 From d4910a5e7bce175d7638ee513fa67b27636f99cd Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 5 Mar 2024 14:32:45 +0100 Subject: QObject: fix a documentation note in the destructor The docs for ~QObject say: > any pending posted events for the object are removed from the event > queue but then they also say: > Deleting a QObject while pending events are waiting to be delivered > can cause a crash These two contradict each other. In fact, the first one is correct, the second one is factually incorrect. Amend it to what I believe it's the intended meaning: do not destroy a QObject which is _handling_ an event (i.e. we're into QObject::event() or an override). Change-Id: Id1d564f296e17a764e0f49ebfedf6e292085c221 Pick-to: 6.2 Reviewed-by: Thiago Macieira Reviewed-by: Shantanu Tushar Reviewed-by: Fabian Kosmale (cherry picked from commit 6e0c438a41a61a3d0a93954f00f46951c4399224) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 23d7faa8a1f69a97d8e094be7e81f907361b02ae) (cherry picked from commit 99766ce294497359dece1b5574d84cc079a95ec5) --- src/corelib/kernel/qobject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 1b719d8c51a..44192332293 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1015,8 +1015,8 @@ void QObjectPrivate::clearBindingStorage() outside the parent. If you still do, the destroyed() signal gives you an opportunity to detect when an object is destroyed. - \warning Deleting a QObject while pending events are waiting to - be delivered can cause a crash. You must not delete the QObject + \warning Deleting a QObject while it is handling an event + delivered to it can cause a crash. You must not delete the QObject directly if it exists in a different thread than the one currently executing. Use deleteLater() instead, which will cause the event loop to delete the object after all pending events have been -- cgit v1.2.3 From 89cbd34afcbde9ab12fc6bf31b0d6f7015af2a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20K=C3=B6hne?= Date: Wed, 6 Mar 2024 16:47:05 +0100 Subject: Use canonical capitalization of Unicode-3.0 SPDX tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SPDX database lists the license as 'Unicode-3.0', and 'Unicode License v3'. Now, the SPDX standard actually says that License identifiers (including license exception identifiers) used in SPDX documents or source code files should be matched in a case- insensitive manner. But the website at https://spdx.org/licenses/ doesn't treat it this way, so the link we generate out of the identifier actually gives a 404. So it's just easier to use the 'original' capitalization. Amends 063026cc503 Change-Id: I826077a914721b7b9499ad62c08fdf20be94e88d Reviewed-by: Mårten Nordheim Reviewed-by: Edward Welbourne (cherry picked from commit 39c4c868a4c1acb5cceb00418b2bb0ca3836d0a3) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit a7a2cf8746d3705e5949073b348d54d51f5aba91) (cherry picked from commit 2cfb0df6b934c99afbb73ba272cbb190780e2420) --- src/corelib/text/qt_attribution.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qt_attribution.json b/src/corelib/text/qt_attribution.json index 0084ccc18d9..3ae1bd2925a 100644 --- a/src/corelib/text/qt_attribution.json +++ b/src/corelib/text/qt_attribution.json @@ -35,8 +35,8 @@ available.", "Homepage": "https://cldr.unicode.org/", "Version": "v44.1", - "License": "Unicode License V3", - "LicenseId": "UNICODE-3.0", + "License": "Unicode License v3", + "LicenseId": "Unicode-3.0", "Copyright": "Copyright (C) 2004-2023 Unicode, Inc." } ] -- cgit v1.2.3 From a16bdba916cbe8dd77cf3e0460ba2f7fbae0e457 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 15 Mar 2024 17:31:47 +0100 Subject: CMake: Check for qtpaths6.exe existence during windows deployment A qt installation might not contain the non-versioned the qtpaths.exe installed, but keep the versioned qtpaths6.exe. Try to use the versioned version before the non-versioned one. If none exists, show a warning at deployment time. Amends 571201603acc731330c9af42a3aca9cda41d38fd Fixes: QTBUG-122664 Task-number: QTBUG-119619 Change-Id: I23caf9ed3c7928fbab9657b0c0c64517dfc7d68e Reviewed-by: Joerg Bornemann (cherry picked from commit bcdc9d7059b6ecd4e0bfb44cf5a42d87c49e3edc) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 06ab1d36302245916558251e400c6a643fe4c2c5) (cherry picked from commit 9409af0fad48e79a5fba495e091894b60e9e3ff7) --- src/corelib/Qt6CoreDeploySupport.cmake | 7 ++++++- src/corelib/Qt6CoreMacros.cmake | 25 ++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/Qt6CoreDeploySupport.cmake b/src/corelib/Qt6CoreDeploySupport.cmake index 999708185ec..b3cfe29160f 100644 --- a/src/corelib/Qt6CoreDeploySupport.cmake +++ b/src/corelib/Qt6CoreDeploySupport.cmake @@ -437,8 +437,13 @@ function(qt6_deploy_runtime_dependencies) # Specify path to target Qt's qtpaths .exe or .bat file, so windeployqt deploys the correct # libraries when cross-compiling from x86_64 to arm64 windows. - if(__QT_DEPLOY_TARGET_QT_PATHS_PATH) + if(__QT_DEPLOY_TARGET_QT_PATHS_PATH AND EXISTS "${__QT_DEPLOY_TARGET_QT_PATHS_PATH}") list(APPEND tool_options --qtpaths "${__QT_DEPLOY_TARGET_QT_PATHS_PATH}") + else() + message(WARNING + "No qtpaths executable found for target Qt " + "at: ${__QT_DEPLOY_TARGET_QT_PATHS_PATH}. " + "Libraries may not be deployed correctly.") endif() elseif(__QT_DEPLOY_SYSTEM_NAME STREQUAL Darwin) diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index c692839b36f..f7f658d5afe 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -2666,7 +2666,30 @@ function(_qt_internal_setup_deploy_support) else() set(qt_paths_ext "") endif() - set(target_qtpaths_path "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_BINS}/qtpaths${qt_paths_ext}") + + + + set(target_qtpaths_path "") + set(qtpaths_prefix "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_BINS}") + get_property(qt_major_version TARGET "${target}" PROPERTY INTERFACE_QT_MAJOR_VERSION) + if(qt_major_version) + set(target_qtpaths_with_major_version_path + "${qtpaths_prefix}/qtpaths${qt_major_version}${qt_paths_ext}") + if(EXISTS "${target_qtpaths_with_major_version_path}") + set(target_qtpaths_path "${target_qtpaths_with_major_version_path}") + endif() + endif() + + if(NOT target_qtpaths_path) + set(target_qtpaths_path_without_version "${qtpaths_prefix}/qtpaths${qt_paths_ext}") + if(EXISTS "${target_qtpaths_path_without_version}") + set(target_qtpaths_path "${target_qtpaths_path_without_version}") + endif() + endif() + + if(NOT target_qtpaths_path) + message(DEBUG "No qtpaths executable found for deployment purposes.") + endif() file(GENERATE OUTPUT "${QT_DEPLOY_SUPPORT}" CONTENT "cmake_minimum_required(VERSION 3.16...3.21) -- cgit v1.2.3 From d40c5d02e7135c6910732280d344f0c493a7539a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wierci=C5=84ski?= Date: Thu, 29 Feb 2024 16:53:07 +0100 Subject: wasm: Dont access QNetworkReply header data through dangling pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-122893 Change-Id: I3768fdffaec7be4ec0b559fdb365600220e648d1 Reviewed-by: Lorn Potter (cherry picked from commit a5b00cefef12999e9a213943855abe6bc0ab5365) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 9a59f6bc574e3b9dfa09ac33e6dd951f105f87bb) Reviewed-by: Piotr Wierciński (cherry picked from commit 8341bfd960a09576f95ebabb1e9ad767e85198b1) --- src/corelib/kernel/qeventdispatcher_wasm_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qeventdispatcher_wasm_p.h b/src/corelib/kernel/qeventdispatcher_wasm_p.h index 94550e65869..1e5b520948a 100644 --- a/src/corelib/kernel/qeventdispatcher_wasm_p.h +++ b/src/corelib/kernel/qeventdispatcher_wasm_p.h @@ -50,6 +50,7 @@ public: void interrupt() override; void wakeUp() override; + static void runOnMainThread(std::function fn); static void runOnMainThreadAsync(std::function fn); static void socketSelect(int timeout, int socket, bool waitForRead, bool waitForWrite, bool *selectForRead, bool *selectForWrite, bool *socketDisconnect); @@ -87,7 +88,6 @@ private: static void run(std::function fn); static void runAsync(std::function fn); - static void runOnMainThread(std::function fn); static QEventDispatcherWasm *g_mainThreadEventDispatcher; -- cgit v1.2.3 From 389a26447943074d63950fd8cd8261daa6c16454 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 1 Mar 2024 15:16:54 +0100 Subject: QProperty: Destroy binding when refcount is 0 This has to be done from all places where we deref it. Otherwise we leak memory. Fixes: QTBUG-116086 Change-Id: I57307ac746205578a920d2bb1e159b66ebd9b2cc Reviewed-by: Fabian Kosmale (cherry picked from commit 717dc9450ffc13ef8209a10073552ac4574a4160) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 933d695ecb5d8e2dbe107e5fd15428a7484ede8f) (cherry picked from commit c3d9c40a65100305f2fd56f13e29b68508c81da7) --- src/corelib/kernel/qproperty.cpp | 7 ------- src/corelib/kernel/qproperty_p.h | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index f683d4241e1..534423b7946 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -732,13 +732,6 @@ void QPropertyObserverPointer::setChangeHandler(QPropertyObserver::ChangeHandler ptr->next.setTag(QPropertyObserver::ObserverNotifiesChangeHandler); } -void QPropertyObserverPointer::setBindingToNotify(QPropertyBindingPrivate *binding) -{ - Q_ASSERT(ptr->next.tag() != QPropertyObserver::ObserverIsPlaceholder); - ptr->binding = binding; - ptr->next.setTag(QPropertyObserver::ObserverNotifiesBinding); -} - /*! \internal The same as as setBindingToNotify, but assumes that the tag is already correct. diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index 105f04dba0d..f7b9ddbb1c7 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -134,7 +134,13 @@ struct QPropertyObserverPointer unlink_common(); } - void setBindingToNotify(QPropertyBindingPrivate *binding); + void setBindingToNotify(QPropertyBindingPrivate *binding) + { + Q_ASSERT(ptr->next.tag() != QPropertyObserver::ObserverIsPlaceholder); + ptr->binding = binding; + ptr->next.setTag(QPropertyObserver::ObserverNotifiesBinding); + } + void setBindingToNotify_unsafe(QPropertyBindingPrivate *binding); void setChangeHandler(QPropertyObserver::ChangeHandler changeHandler); @@ -937,7 +943,15 @@ QBindingObserverPtr::QBindingObserverPtr(QPropertyObserver *observer) noexcept : QPropertyObserverPointer{d}.binding()->addRef(); } -QBindingObserverPtr::~QBindingObserverPtr() { if (d) QPropertyObserverPointer{d}.binding()->deref(); } +QBindingObserverPtr::~QBindingObserverPtr() +{ + if (!d) + return; + + QPropertyBindingPrivate *bindingPrivate = binding(); + if (!bindingPrivate->deref()) + QPropertyBindingPrivate::destroyAndFreeMemory(bindingPrivate); +} QPropertyBindingPrivate *QBindingObserverPtr::binding() const noexcept { return QPropertyObserverPointer{d}.binding(); } -- cgit v1.2.3 From bb3d6f96af6928a8ad6841b2ea5191701ed5710c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 16 Mar 2024 18:41:27 -0700 Subject: QDBusArgument: disambiguate between QMap on std::pair and std::map For QMap on a std::pair, QMap::iterator{}.operator->() would result in a type that has "first" and "second" members: std::pair itself. But it would be wrong to marshall and demarshall the first and second elements thereof as the key and value, so give preference to the .key() and .value() selection, which would store the std::pair as the type. Fixes: QTBUG-123401 Change-Id: I6818d78a57394e37857bfffd17bd69bb692dd03b Reviewed-by: Alexey Edelev (cherry picked from commit 5401a9a6cd3263eda15911c3fbfc81ebea2e798f) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 9ffed81b159e9bdf4aba26dfdbd08ff508ffe8b3) (cherry picked from commit 1e11f8fa80e5bbce11d0dfe7213d8af1e8c10fe3) --- src/corelib/tools/qcontainertools_impl.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qcontainertools_impl.h b/src/corelib/tools/qcontainertools_impl.h index 42627e22dfb..95fd4555573 100644 --- a/src/corelib/tools/qcontainertools_impl.h +++ b/src/corelib/tools/qcontainertools_impl.h @@ -265,7 +265,11 @@ using IfAssociativeIteratorHasKeyAndValue = template using IfAssociativeIteratorHasFirstAndSecond = - std::enable_if_t, bool>; + std::enable_if_t< + std::conjunction_v< + std::negation>, + qxp::is_detected + >, bool>; template using IfIsNotSame = -- cgit v1.2.3 From 07408b1c1fff75f882c60eabe19c029a661cc71f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 19 Mar 2024 09:25:42 +0100 Subject: Suppress bogus warning from gcc 12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It says: /home/qt/qt6dev-src/qtbase/src/corelib/tools/qcontainertools_impl.h: In function ‘auto QtPrivate::sequential_erase_with_copy(Container&, const T&) [with Container = QList; T = void (*)()]’: /home/qt/qt6dev-src/qtbase/src/corelib/tools/qcontainertools_impl.h:383:14: error: ‘D.282000’ is used uninitialized [-Werror=uninitialized] 383 | const T &tCopy = CopyProxy(t); | ^~~~~ cc1plus: all warnings being treated as errors We can avoid storing the value into a const ref to silence this. Storing a non-const pointer into a const reference is quite confusing anyway. Fixes: QTBUG-123486 Change-Id: I77fcd871724ce7f81b9567603dc5b4cb31f121c5 Reviewed-by: Thiago Macieira (cherry picked from commit 4662e80755b3002585280cfe9076d2c6c14f1e5b) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 24cc41f77fefa20d4bf4acb6dd1a96b2371ebfd2) (cherry picked from commit daa5b56cd214a8b06da632b3280f1a75f0d69dde) --- src/corelib/tools/qcontainertools_impl.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qcontainertools_impl.h b/src/corelib/tools/qcontainertools_impl.h index 95fd4555573..7897a758467 100644 --- a/src/corelib/tools/qcontainertools_impl.h +++ b/src/corelib/tools/qcontainertools_impl.h @@ -327,8 +327,7 @@ template auto sequential_erase_with_copy(Container &c, const T &t) { using CopyProxy = std::conditional_t, T, const T &>; - const T &tCopy = CopyProxy(t); - return sequential_erase(c, tCopy); + return sequential_erase(c, CopyProxy(t)); } template -- cgit v1.2.3 From d278a28703f87550d1fbb39181cffb2e436d0416 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 8 Mar 2024 10:36:11 +0100 Subject: QObjectPrivate: fix data race on ConnectionData contents The atomic pointer "connections" is always populated under mutex in QObjectPrivate::ensureConnectionData() but isn't necessarily read under mutex protection (e.g. in maybeSignalConnected()). This caused a data race, fixed by using storeRelease and loadAcquired. Task-number: QTBUG-100336 Change-Id: Ifd605e65122248eb08f49e036fdda6e6564226bc Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira (cherry picked from commit 75d82afa0d3aad9b4f9857e439535fc49c4616bc) (cherry picked from commit 67487f004c48ee045cc0be476249b2786d606a67) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit d89c9e7310541e73024ed6a76945b0ece7509f4b) --- src/corelib/kernel/qobject.cpp | 40 ++++++++++++++++++++++++---------------- src/corelib/kernel/qobject_p_p.h | 11 +++++------ 2 files changed, 29 insertions(+), 22 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 44192332293..266087fe88b 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -252,7 +252,7 @@ QObjectList QObjectPrivate::receiverList(const char *signal) const { QObjectList returnValue; int signal_index = signalIndex(signal); - ConnectionData *cd = connections.loadRelaxed(); + ConnectionData *cd = connections.loadAcquire(); if (signal_index < 0 || !cd) return returnValue; if (signal_index < cd->signalVectorCount()) { @@ -281,13 +281,17 @@ QObjectList QObjectPrivate::senderList() const return returnValue; } +/*! + \internal + The signalSlotLock() of the sender must be locked while calling this function +*/ inline void QObjectPrivate::ensureConnectionData() { if (connections.loadRelaxed()) return; ConnectionData *cd = new ConnectionData; cd->ref.ref(); - connections.storeRelaxed(cd); + connections.storeRelease(cd); } /*! @@ -452,7 +456,7 @@ bool QObjectPrivate::isSignalConnected(uint signalIndex, bool checkDeclarative) if (checkDeclarative && isDeclarativeSignalConnected(signalIndex)) return true; - ConnectionData *cd = connections.loadRelaxed(); + ConnectionData *cd = connections.loadAcquire(); if (!cd) return false; SignalVector *signalVector = cd->signalVector.loadRelaxed(); @@ -475,7 +479,7 @@ bool QObjectPrivate::isSignalConnected(uint signalIndex, bool checkDeclarative) bool QObjectPrivate::maybeSignalConnected(uint signalIndex) const { - ConnectionData *cd = connections.loadRelaxed(); + ConnectionData *cd = connections.loadAcquire(); if (!cd) return false; SignalVector *signalVector = cd->signalVector.loadRelaxed(); @@ -1065,7 +1069,7 @@ QObject::~QObject() if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::destroyed) QAbstractDeclarativeData::destroyed(d->declarativeData, this); - QObjectPrivate::ConnectionData *cd = d->connections.loadRelaxed(); + QObjectPrivate::ConnectionData *cd = d->connections.loadAcquire(); if (cd) { if (cd->currentSender) { cd->currentSender->receiverDeleted(); @@ -1429,11 +1433,13 @@ bool QObject::event(QEvent *e) { QAbstractMetaCallEvent *mce = static_cast(e); - if (!d_func()->connections.loadRelaxed()) { + QObjectPrivate::ConnectionData *connections = d_func()->connections.loadAcquire(); + if (!connections) { QMutexLocker locker(signalSlotLock(this)); d_func()->ensureConnectionData(); + connections = d_func()->connections.loadRelaxed(); } - QObjectPrivate::Sender sender(this, const_cast(mce->sender()), mce->signalId()); + QObjectPrivate::Sender sender(this, const_cast(mce->sender()), mce->signalId(), connections); mce->placeMetaCall(this); break; @@ -1766,7 +1772,7 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData } // the current emitting thread shouldn't restore currentSender after calling moveToThread() - ConnectionData *cd = connections.loadRelaxed(); + ConnectionData *cd = connections.loadAcquire(); if (cd) { if (cd->currentSender) { cd->currentSender->receiverDeleted(); @@ -2709,8 +2715,8 @@ int QObject::receivers(const char *signal) const signal_index); } - QObjectPrivate::ConnectionData *cd = d->connections.loadRelaxed(); QMutexLocker locker(signalSlotLock(this)); + QObjectPrivate::ConnectionData *cd = d->connections.loadRelaxed(); if (cd && signal_index < cd->signalVectorCount()) { const QObjectPrivate::Connection *c = cd->signalVector.loadRelaxed()->at(signal_index).first.loadRelaxed(); while (c) { @@ -3968,8 +3974,8 @@ void doActivate(QObject *sender, int signal_index, void **argv) bool senderDeleted = false; { - Q_ASSERT(sp->connections.loadAcquire()); - QObjectPrivate::ConnectionDataPointer connections(sp->connections.loadRelaxed()); + Q_ASSERT(sp->connections.loadRelaxed()); + QObjectPrivate::ConnectionDataPointer connections(sp->connections.loadAcquire()); QObjectPrivate::SignalVector *signalVector = connections->signalVector.loadRelaxed(); const QObjectPrivate::ConnectionList *list; @@ -4045,7 +4051,9 @@ void doActivate(QObject *sender, int signal_index, void **argv) if (c->isSingleShot && !QObjectPrivate::removeConnection(c)) continue; - QObjectPrivate::Sender senderData(receiverInSameThread ? receiver : nullptr, sender, signal_index); + QObjectPrivate::Sender senderData( + receiverInSameThread ? receiver : nullptr, sender, signal_index, + receiverInSameThread ? QObjectPrivate::get(receiver)->connections.loadAcquire() : nullptr); if (c->isSlotObject) { SlotObjectGuard obj{c->slotObj}; @@ -4094,7 +4102,7 @@ void doActivate(QObject *sender, int signal_index, void **argv) senderDeleted = true; } if (!senderDeleted) { - sp->connections.loadRelaxed()->cleanOrphanedConnections(sender); + sp->connections.loadAcquire()->cleanOrphanedConnections(sender); if (callbacks_enabled && signal_spy_set->signal_end_callback != nullptr) signal_spy_set->signal_end_callback(sender, signal_index); @@ -5154,9 +5162,9 @@ QMetaObject::Connection QObjectPrivate::connectImpl(const QObject *sender, int s QOrderedMutexLocker locker(signalSlotLock(sender), signalSlotLock(receiver)); - if (type & Qt::UniqueConnection && slot && QObjectPrivate::get(s)->connections.loadRelaxed()) { + if (type & Qt::UniqueConnection && slot) { QObjectPrivate::ConnectionData *connections = QObjectPrivate::get(s)->connections.loadRelaxed(); - if (connections->signalVectorCount() > signal_index) { + if (connections && connections->signalVectorCount() > signal_index) { const QObjectPrivate::Connection *c2 = connections->signalVector.loadRelaxed()->at(signal_index).first.loadRelaxed(); while (c2) { @@ -5433,7 +5441,7 @@ inline bool QObjectPrivate::removeConnection(QObjectPrivate::Connection *c) QtPrivate::QPropertyAdaptorSlotObject * QObjectPrivate::getPropertyAdaptorSlotObject(const QMetaProperty &property) { - if (auto conns = connections.loadRelaxed()) { + if (auto conns = connections.loadAcquire()) { Q_Q(QObject); const QMetaObject *metaObject = q->metaObject(); int signal_index = methodIndexToSignalIndex(&metaObject, property.notifySignalIndex()); diff --git a/src/corelib/kernel/qobject_p_p.h b/src/corelib/kernel/qobject_p_p.h index 683be997d5c..ee4ec9f5eec 100644 --- a/src/corelib/kernel/qobject_p_p.h +++ b/src/corelib/kernel/qobject_p_p.h @@ -215,19 +215,18 @@ struct QObjectPrivate::ConnectionData struct QObjectPrivate::Sender { - Sender(QObject *receiver, QObject *sender, int signal) + Sender(QObject *receiver, QObject *sender, int signal, ConnectionData *receiverConnections) : receiver(receiver), sender(sender), signal(signal) { - if (receiver) { - ConnectionData *cd = receiver->d_func()->connections.loadRelaxed(); - previous = cd->currentSender; - cd->currentSender = this; + if (receiverConnections) { + previous = receiverConnections->currentSender; + receiverConnections->currentSender = this; } } ~Sender() { if (receiver) - receiver->d_func()->connections.loadRelaxed()->currentSender = previous; + receiver->d_func()->connections.loadAcquire()->currentSender = previous; } void receiverDeleted() { -- cgit v1.2.3 From f90e057837cdbf37b5d68e7d449f5d50eefc341a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 20 Mar 2024 10:41:56 +0100 Subject: QObjectPrivate::Signal: initialize all members A recent change in that area triggered Clang-SA to rescan the code and complain about this pre-existing bug: If receiver == nullptr, then the `previous` member was never initialized. Fix by null'ing it using NSDMI. This is a trivial type, the compiler will be able to avoid the redundant write. Amends ab92b9e40025dcf08c14232de762a268201a78b4(!). Pick-to: 6.2 5.15 Change-Id: Ideed71f0f36d5f896fb6a4614f233757c1371ee3 Reviewed-by: David Faure Reviewed-by: Edward Welbourne (cherry picked from commit 40714c1ddd886f6d0bde53e05f27d6b3e9e6649b) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit beabcc543640bdde4e88eeff5cd614d021c00f51) (cherry picked from commit f05798653b6c6254ab9a08de241fd28c189420a7) --- src/corelib/kernel/qobject_p_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobject_p_p.h b/src/corelib/kernel/qobject_p_p.h index ee4ec9f5eec..672c88836cf 100644 --- a/src/corelib/kernel/qobject_p_p.h +++ b/src/corelib/kernel/qobject_p_p.h @@ -236,7 +236,7 @@ struct QObjectPrivate::Sender s = s->previous; } } - Sender *previous; + Sender *previous = nullptr; QObject *receiver; QObject *sender; int signal; -- cgit v1.2.3 From d50ba5ff5ec0d2ed78643043278950b58ac2cb08 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 6 Oct 2023 09:53:26 -0700 Subject: Remove Qt_6_PRIVATE_API ELF version from a symbol used by QFuture::then() QFuture::then() uses QtPrivate::Continuation::create(), which in turn uses private API from an inline function: f->d.setContinuation(ContinuationWrapper(std::move(continuation)), fi.d); f->d is QFutureInterfaceBase (a public class), but its setContinuation() takes QFutureInterfaceBasePrivate by pointer. Our ELF versioning scripts mark everything that uses that class as private, resulting in: 4806: 0000000000287d70 365 FUNC GLOBAL PROTECTED 16 _ZN20QFutureInterfaceBase15setContinuationESt8functionIFvRKS_EEP27QFutureInterfaceBasePrivate@@Qt_6_PRIVATE_API This commit adds an exception for this symbol, causing it to go back to the regular "Qt_6" ELF version: 5629: 00000000003d6a16 366 FUNC GLOBAL PROTECTED 16 _ZN20QFutureInterfaceBase15setContinuationESt8functionIFvRKS_EEP27QFutureInterfaceBasePrivate@@Qt_6 This solution can probably be cleaned up a bit by moving the marker into the header files parsed by syncqt, so they follow code motion without having to remember to update the CMakeLists.txt. That requires some surgery with syncqt, so not suitable for cherry-picking. As a drive-by, fix the target_type check for the _qt_extra_linker_script_content genex property Fixes: QTBUG-117514 Fixes: QTBUG-123429 Change-Id: I85599ea5ca7a4b79a8bbfffd178b92e73dbe11de Reviewed-by: Joerg Bornemann (cherry picked from commit 0f0371c8304bd7354a3c43f9fac6b85bd3e9a3f1) Reviewed-by: Alexandru Croitor --- src/corelib/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 2df45916269..c44bdf6c6d6 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -1408,4 +1408,10 @@ foreach(minor_version RANGE ${PROJECT_VERSION_MINOR}) endforeach() qt_internal_extend_target(Core EXTRA_LINKER_SCRIPT_CONTENT "${linker_script_contents}" + + # Workaround for QTBUG-117514: + # Function called by inline methods taking a pointer to a private class as a parameter + EXTRA_LINKER_SCRIPT_EXPORTS + # QFutureInterfaceBase::setContinuation(std::function, QFutureInterfaceBasePrivate*) + "_ZN20QFutureInterfaceBase15setContinuationE*P27QFutureInterfaceBasePrivate" ) -- cgit v1.2.3 From f9e79171b6228de4a223c19c82b76ed1d5b4524b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 20 Mar 2024 17:14:41 +0100 Subject: QMetaMethod: document that fromSignal(nullptr) is ok MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... and add a test. Pick-to: 6.2 5.15 Change-Id: I907899d7c54349d2fc23ea5ab58a1e67826b622b Reviewed-by: Thiago Macieira Reviewed-by: Mårten Nordheim (cherry picked from commit 78db468f4895911e50849223899abf2c5fb1c72e) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 9f14d0a288ef5355ca92e64fe464735f119b8ec5) (cherry picked from commit fcd465512aa78039123343da86610a36f509878e) --- src/corelib/kernel/qmetaobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 97bc2f160c3..12a8038c612 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -2338,7 +2338,7 @@ QMetaMethod::MethodType QMetaMethod::methodType() const \since 5.0 Returns the meta-method that corresponds to the given \a signal, or an - invalid QMetaMethod if \a signal is not a signal of the class. + invalid QMetaMethod if \a signal is \c{nullptr} or not a signal of the class. Example: -- cgit v1.2.3 From 18d90920e4d35756b271a45cde3da8b6844e14f9 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Tue, 19 Mar 2024 16:05:32 +0100 Subject: Use the correctly versioned variable when resolving ABI-specific cmake directory Use the QT_CMAKE_EXPORT_NAMESPACE prefixed INSTALL_LIBS variable when resolving the cmake path of the ABI-specific cmake directory. Change-Id: Ibc4a1b152135d840de104c15a183b13fca0739ea Reviewed-by: Alexandru Croitor Reviewed-by: Qt CI Bot (cherry picked from commit df8c3d40c85465027de375f656684badc6247121) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 539c6b6f76cd89d57506a6a540f593ed558eccc8) (cherry picked from commit 887f2595afd217e9f28b466a400bd60e9e34ceba) --- src/corelib/Qt6AndroidMacros.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake index 83b82f3e4ba..66f508f3b23 100644 --- a/src/corelib/Qt6AndroidMacros.cmake +++ b/src/corelib/Qt6AndroidMacros.cmake @@ -1011,7 +1011,8 @@ function(_qt_internal_get_android_abi_cmake_dir_path out_path abi) NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_INTERNAL_IS_STANDALONE_TEST) set(cmake_dir "${QT_CONFIG_BUILD_DIR}") else() - set(cmake_dir "${prefix_path}/${QT6_INSTALL_LIBS}/cmake") + string(TOUPPER "${QT_CMAKE_EXPORT_NAMESPACE}" export_namespace_upper) + set(cmake_dir "${prefix_path}/${${export_namespace_upper}_INSTALL_LIBS}/cmake") endif() endif() -- cgit v1.2.3 From 9884be691c331152da97846d2ffb6391a8c1f84b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 11 Mar 2024 11:24:00 -0400 Subject: QFutureInterface: fix build with GCC14/C++20: template-id not allowed When declaring a constructor, you must use the injected name, not a template. qfutureinterface.h:472:37: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor] Pick-to: 6.2 5.15 Change-Id: I6818d78a57394e37857bfffd17bbbf2313001cbf Reviewed-by: Ahmad Samir (cherry picked from commit 111c08d0eaa134652f1f1e602ead1a539614258f) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit af41847af512f2fb2329cc6b258f6de79ab1355b) (cherry picked from commit d75965ee24d9f3e9097688f184fc389f5d5d1528) Reviewed-by: Liang Qi --- src/corelib/thread/qfutureinterface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h index 82c2cc2ca98..26c1974e82b 100644 --- a/src/corelib/thread/qfutureinterface.h +++ b/src/corelib/thread/qfutureinterface.h @@ -452,7 +452,7 @@ template <> class QFutureInterface : public QFutureInterfaceBase { public: - explicit QFutureInterface(State initialState = NoState) + explicit QFutureInterface(State initialState = NoState) : QFutureInterfaceBase(initialState) { } -- cgit v1.2.3 From ffbb4fa7734395bc2b6f6cd38dfec7080488620d Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Tue, 26 Mar 2024 10:18:59 +0100 Subject: Add the note about data size to QByteArray::operator=(const char*) Add the note about the way the str size is determined when using QByteArray::operator=(const char*). Change-Id: I39b2d0fc2967832622fbf0c11b3ff6c7ff99b8f2 Reviewed-by: Thiago Macieira Reviewed-by: Leena Miettinen (cherry picked from commit 32e2386b157effa5f253ffd669ed52471863823b) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 41ecbdf4670171f1d9f68fb6ccd74ef4b05368cd) (cherry picked from commit 1fc5527e2d9319e23dd7f419de216d60e90ac2c4) --- src/corelib/text/qbytearray.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index d2ca79e78d2..cc0eb0f98c1 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -1342,6 +1342,9 @@ QByteArray &QByteArray::operator=(const QByteArray & other) noexcept \overload Assigns \a str to this byte array. + + \a str is assumed to point to a null-terminated string, and its length is + determined dynamically. */ QByteArray &QByteArray::operator=(const char *str) -- cgit v1.2.3 From 190d695b6c55036afd2858760d90b69f0d5b22d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 4 Apr 2024 13:32:31 +0300 Subject: QTypeInfo: Add a missing include This header uses std::is_trivial_v, which requires including the header. When building with PCH enabled (which is the default), this dependency does get satisfied via the PCH, so no issue is visible. This fixes building with recent version of libc++ when configured with _LIBCPP_REMOVE_TRANSITIVE_INCLUDES (which removes unnecessary transitive dependencies between the libc++ headers, a configuration which may become the default in the future), with PCH disabled. Pick-to: 6.2 Change-Id: I5e3ae20e366ed3028b1156cee05bcf2908d6e845 Reviewed-by: Giuseppe D'Angelo (cherry picked from commit adb49d65e0774fa6be0b0d9d490c6f1fc5066a1b) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit efea1f981f44d079e2a4abc9ff228ade069f42a8) --- src/corelib/global/qtypeinfo.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index f7f1e85989b..3b774c93790 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -7,6 +7,7 @@ #include #include #include +#include #ifndef QTYPEINFO_H #define QTYPEINFO_H -- cgit v1.2.3 From 6e75dea7598bc3f0fff14e34dc30e64b736de36b Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 5 Apr 2024 16:50:47 +0200 Subject: Pass trivially-copyable types by value, not by const ref The LikelyPair and QLocaleId types are small enough to pass by value. Task-number: QTBUG-122619 Change-Id: I1502efcf69ac82d9c49b673975502882c59a4fd0 Reviewed-by: Thiago Macieira (cherry picked from commit 738914e787c5a2de57f40753b665e2a49f9536d3) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 84d5754a816add82867c49fb6a3d15287029d1ed) --- src/corelib/text/qlocale.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 9818ff92b8f..51c9cb507e4 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -250,7 +250,7 @@ struct LikelyPair QLocaleId value = QLocaleId { 0, 0, 0 }; }; -bool operator<(const LikelyPair &lhs, const LikelyPair &rhs) +bool operator<(LikelyPair lhs, LikelyPair rhs) { // Must match the comparison LocaleDataWriter.likelySubtags() uses when // sorting, see qtbase/util/locale_database.qlocalexml2cpp.py @@ -461,7 +461,7 @@ QByteArray QLocalePrivate::bcp47Name(char separator) const return m_data->id().withLikelySubtagsRemoved().name(separator); } -static qsizetype findLocaleIndexById(const QLocaleId &localeId) +static qsizetype findLocaleIndexById(QLocaleId localeId) { qsizetype idx = locale_index[localeId.language_id]; // If there are no locales for specified language (so we we've got the -- cgit v1.2.3 From 719121366cd854e1d4cb4354defeeb9753e22c0f Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 5 Apr 2024 16:39:52 +0200 Subject: QLocale: pass 64-bit LanguageCodeEntry by value, not const ref Probably makes no difference, since it's all in lambdas being passed to a standard algorithm, but the static analyser noticed this would be cleaner. Task-number: QTBUG-122619 Change-Id: I23093254e4857131b7be87aeff1e7ba79ea2b674 Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira (cherry picked from commit e1da249be602322c3e4b84ba23748c1c1c8db888) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 4c25cb76eb224bbd315dc5e0c7bf18644205a294) --- src/corelib/text/qlocale.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 51c9cb507e4..563a1205463 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -109,18 +109,18 @@ QLocale::Language QLocalePrivate::codeToLanguage(QStringView code, auto searchCode = [codeBuf](auto f) { return std::find_if(languageCodeList.begin(), languageCodeList.end(), - [=](const LanguageCodeEntry &i) { return f(i) == codeBuf; }); + [=](LanguageCodeEntry i) { return f(i) == codeBuf; }); }; if (codeTypes.testFlag(QLocale::ISO639Part1) && uc3 == 0) { - auto i = searchCode([](const LanguageCodeEntry &i) { return i.part1; }); + auto i = searchCode([](LanguageCodeEntry i) { return i.part1; }); if (i != languageCodeList.end()) return QLocale::Language(std::distance(languageCodeList.begin(), i)); } if (uc3 != 0) { if (codeTypes.testFlag(QLocale::ISO639Part2B)) { - auto i = searchCode([](const LanguageCodeEntry &i) { return i.part2B; }); + auto i = searchCode([](LanguageCodeEntry i) { return i.part2B; }); if (i != languageCodeList.end()) return QLocale::Language(std::distance(languageCodeList.begin(), i)); } @@ -129,13 +129,13 @@ QLocale::Language QLocalePrivate::codeToLanguage(QStringView code, // This is asserted in iso639_3.LanguageCodeData. if (codeTypes.testFlag(QLocale::ISO639Part2T) && !codeTypes.testFlag(QLocale::ISO639Part3)) { - auto i = searchCode([](const LanguageCodeEntry &i) { return i.part2T; }); + auto i = searchCode([](LanguageCodeEntry i) { return i.part2T; }); if (i != languageCodeList.end()) return QLocale::Language(std::distance(languageCodeList.begin(), i)); } if (codeTypes.testFlag(QLocale::ISO639Part3)) { - auto i = searchCode([](const LanguageCodeEntry &i) { return i.part3; }); + auto i = searchCode([](LanguageCodeEntry i) { return i.part3; }); if (i != languageCodeList.end()) return QLocale::Language(std::distance(languageCodeList.begin(), i)); } -- cgit v1.2.3 From d6863a8028ce4f706fe7f426a8d5a5a8f6f182db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wierci=C5=84ski?= Date: Thu, 4 Apr 2024 10:20:59 +0000 Subject: Revert "wasm: Proxy emscripten_fetch() to the main thread" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f2f2b6ef18907a76461b54e110618e7840971fa7. Reason for revert: There are couple of issues introduced. Lets revert to base revision and go with fixes from there. Change-Id: I8341de42ef3e4a609bfbffdb763dd5c28794473c Reviewed-by: Morten Johan Sørvig Reviewed-by: Qt CI Bot Reviewed-by: Even Oscar Andersen (cherry picked from commit 157c9eef48916c3e11f43ffb0fe8e8030bed8d06) Reviewed-by: Piotr Wierciński (cherry picked from commit bc9d2230d85a694a9a4a2b358e4a299960a51c2a) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qeventdispatcher_wasm_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qeventdispatcher_wasm_p.h b/src/corelib/kernel/qeventdispatcher_wasm_p.h index 1e5b520948a..f7d8b955e85 100644 --- a/src/corelib/kernel/qeventdispatcher_wasm_p.h +++ b/src/corelib/kernel/qeventdispatcher_wasm_p.h @@ -51,7 +51,6 @@ public: void wakeUp() override; static void runOnMainThread(std::function fn); - static void runOnMainThreadAsync(std::function fn); static void socketSelect(int timeout, int socket, bool waitForRead, bool waitForWrite, bool *selectForRead, bool *selectForWrite, bool *socketDisconnect); protected: @@ -88,6 +87,7 @@ private: static void run(std::function fn); static void runAsync(std::function fn); + static void runOnMainThreadAsync(std::function fn); static QEventDispatcherWasm *g_mainThreadEventDispatcher; -- cgit v1.2.3 From f57899e191acad2dcdf76cfb4d71c96379812c41 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 5 Apr 2024 15:50:19 +0200 Subject: Pass QVariant to QSystemLocale::query() as rvalue reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QVariant is rather big for passing by value; and no caller has any further use for the QVariant it's passing in. File qlocale_wasm.cpp was added after 6.5, so drop its change. Task-number: QTBUG-122619 Change-Id: I2751745e715aacfa8982ac97b4ae777fde5e88de Reviewed-by: Thiago Macieira (cherry picked from commit b68f1009187fee473f4c6477ec64300650e29904) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 644eca89ed288adbcd7a4a604797be567796711d) Reviewed-by: Mårten Nordheim --- src/corelib/text/qlocale.qdoc | 2 +- src/corelib/text/qlocale_mac.mm | 2 +- src/corelib/text/qlocale_p.h | 2 +- src/corelib/text/qlocale_unix.cpp | 7 ++++--- src/corelib/text/qlocale_win.cpp | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qlocale.qdoc b/src/corelib/text/qlocale.qdoc index fcc4ab4cfb1..f81c10a87fe 100644 --- a/src/corelib/text/qlocale.qdoc +++ b/src/corelib/text/qlocale.qdoc @@ -1153,7 +1153,7 @@ */ /*! - \fn QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const + \fn QVariant QSystemLocale::query(QueryType type, QVariant &&in = QVariant()) const Generic query method for locale data. Provides indirection. Denotes the \a type of the query diff --git a/src/corelib/text/qlocale_mac.mm b/src/corelib/text/qlocale_mac.mm index 0fedc2594de..b6b4b4bb394 100644 --- a/src/corelib/text/qlocale_mac.mm +++ b/src/corelib/text/qlocale_mac.mm @@ -571,7 +571,7 @@ static QLocale::Language codeToLanguage(QStringView s) return QLocalePrivate::codeToLanguage(s); } -QVariant QSystemLocale::query(QueryType type, QVariant in) const +QVariant QSystemLocale::query(QueryType type, QVariant &&in) const { QMacAutoReleasePool pool; diff --git a/src/corelib/text/qlocale_p.h b/src/corelib/text/qlocale_p.h index d97f459528b..c0aad17c81a 100644 --- a/src/corelib/text/qlocale_p.h +++ b/src/corelib/text/qlocale_p.h @@ -98,7 +98,7 @@ public: StandaloneDayNameShort, // QString, in: int StandaloneDayNameNarrow // QString, in: int }; - virtual QVariant query(QueryType type, QVariant in = QVariant()) const; + virtual QVariant query(QueryType type, QVariant &&in = QVariant()) const; virtual QLocale fallbackLocale() const; inline qsizetype fallbackLocaleIndex() const; diff --git a/src/corelib/text/qlocale_unix.cpp b/src/corelib/text/qlocale_unix.cpp index 03e332367ed..09f46597b22 100644 --- a/src/corelib/text/qlocale_unix.cpp +++ b/src/corelib/text/qlocale_unix.cpp @@ -124,7 +124,7 @@ QLocale QSystemLocale::fallbackLocale() const return QLocale(lang); } -QVariant QSystemLocale::query(QueryType type, QVariant in) const +QVariant QSystemLocale::query(QueryType type, QVariant &&in) const { QSystemLocaleData *d = qSystemLocaleData(); @@ -258,9 +258,10 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const return d->uiLanguages.isEmpty() ? QVariant() : QVariant(d->uiLanguages); } case StringToStandardQuotation: - return lc_messages.quoteString(qvariant_cast(in)); + return lc_messages.quoteString(qvariant_cast(std::move(in))); case StringToAlternateQuotation: - return lc_messages.quoteString(qvariant_cast(in), QLocale::AlternateQuotation); + return lc_messages.quoteString(qvariant_cast(std::move(in)), + QLocale::AlternateQuotation); case ListToSeparatedString: return lc_messages.createSeparatedList(in.toStringList()); case LocaleChanged: diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index 7fae5585ac5..66fcea64197 100644 --- a/src/corelib/text/qlocale_win.cpp +++ b/src/corelib/text/qlocale_win.cpp @@ -837,7 +837,7 @@ QLocale QSystemLocale::fallbackLocale() const return QLocale(QString::fromLatin1(getWinLocaleName())); } -QVariant QSystemLocale::query(QueryType type, QVariant in) const +QVariant QSystemLocale::query(QueryType type, QVariant &&in) const { QSystemLocalePrivate *d = systemLocalePrivate(); switch(type) { -- cgit v1.2.3 From 4be9bb498fb3618e5953154a11f1653271b7b1f6 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 5 Apr 2024 15:15:13 +0200 Subject: QSystemLocale(): disable copy and move Axivion (SV546) points out (based on a clazy "rule of three" that might be rule of five by now) the lack of move and copy assignment and construction. We don't want those anyway, so tell the compiler not to create them. Task-number: QTBUG-122619 Change-Id: Ie951a2c3d60d76ad3448310d3f9bbda22190015b Reviewed-by: Giuseppe D'Angelo Reviewed-by: Thiago Macieira (cherry picked from commit 21ef6d930ad3eb2fb435cd601692cb5cc1726bd8) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit a07c718c17df4d376c4fcf5caf67e086a4f0bd53) --- src/corelib/text/qlocale_p.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') diff --git a/src/corelib/text/qlocale_p.h b/src/corelib/text/qlocale_p.h index c0aad17c81a..8de5d7f0d85 100644 --- a/src/corelib/text/qlocale_p.h +++ b/src/corelib/text/qlocale_p.h @@ -35,6 +35,7 @@ struct QLocaleData; // Subclassed by Android platform plugin: class Q_CORE_EXPORT QSystemLocale { + Q_DISABLE_COPY_MOVE(QSystemLocale) QSystemLocale *next = nullptr; // Maintains a stack. public: QSystemLocale(); -- cgit v1.2.3 From 52ccb75caf2cc1fd776e62fb4f442c53b91ea762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 9 Apr 2024 14:03:29 +0300 Subject: QStringTokenizer: Add a missing include MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This header uses std::forward_iterator_tag, which requires including the header. This fixes building with libc++ with _LIBCPP_REMOVE_TRANSITIVE_INCLUDES enabled. Pick-to: 6.2 Change-Id: Id2ce97e158c87dab1efe30e54a93f0bc9351de5a Reviewed-by: Thiago Macieira Reviewed-by: Mårten Nordheim (cherry picked from commit aa896ca9f51252b6d01766e19a03e41bd49857f3) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 3162f7a6ad5b6ff1f095e3aff62282191dc24572) --- src/corelib/text/qstringtokenizer.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') diff --git a/src/corelib/text/qstringtokenizer.h b/src/corelib/text/qstringtokenizer.h index 414fe693159..c75fbbe50f6 100644 --- a/src/corelib/text/qstringtokenizer.h +++ b/src/corelib/text/qstringtokenizer.h @@ -5,6 +5,7 @@ #include #include +#include QT_BEGIN_NAMESPACE -- cgit v1.2.3 From 57f25b705bf2e82e184bec8754b351bdcecc1035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 15 Feb 2024 13:42:24 +0100 Subject: QLocal8Bit::convertFromUnicode[win]: limit fprintf to !NDEBUG Because there is no other way to stop it from printing the output. Change-Id: Ie6dcb393351f50691366849ba85d60e2e186f9fb Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira (cherry picked from commit 1dd89bfb04515bd2e431f8915256a417d622288f) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit d059d5c3cb9dddcc55cf5291cd1b7222169d105b) --- src/corelib/text/qstringconverter.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index ec87f0264e2..6ca65ba6ad8 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -1576,9 +1576,11 @@ QByteArray QLocal8Bit::convertFromUnicode_sys(QStringView in, quint32 codePage, // incomplete sequence, probably a Windows bug. We try to avoid that from // happening by reducing the window size in that case. But let's keep this // branch just in case of other bugs. +#ifndef QT_NO_DEBUG r = GetLastError(); fprintf(stderr, "WideCharToMultiByte: Cannot convert multibyte text (error %d)\n", r); +#endif // !QT_NO_DEBUG break; } std::tie(out, outlen) = growOut(neededLength); -- cgit v1.2.3 From a5048b1f82b278cc521a183e9c1ba8c2bcc43184 Mon Sep 17 00:00:00 2001 From: Rym Bouabid Date: Mon, 8 Apr 2024 17:31:06 +0200 Subject: QCborMap::ConstIterator and Iterator: Add missing destructor Axivion (SV403 and SV404) points out, based on rule of three, the lack of destructors for ConstIterator and Iterator. So add them. Task-number: QTBUG-122619 Change-Id: I4d4abf9be8be529492bf13069052ae4a8d8a90de Reviewed-by: Thiago Macieira (cherry picked from commit b9cb2f30f1568e6cbf8e13d61501babcb90d46b2) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 61885e26e42b766a4db3d67e9b188e601ce8d830) --- src/corelib/serialization/qcbormap.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/serialization/qcbormap.h b/src/corelib/serialization/qcbormap.h index ee9cc35631f..a32c1674e69 100644 --- a/src/corelib/serialization/qcbormap.h +++ b/src/corelib/serialization/qcbormap.h @@ -40,6 +40,7 @@ public: constexpr Iterator() = default; constexpr Iterator(const Iterator &) = default; + ~Iterator() = default; Iterator &operator=(const Iterator &other) { // rebind the reference @@ -100,6 +101,7 @@ public: constexpr ConstIterator() = default; constexpr ConstIterator(const ConstIterator &) = default; + ~ConstIterator() = default; ConstIterator &operator=(const ConstIterator &other) { // rebind the reference -- cgit v1.2.3 From 8f8de922eca1a6a8b1131e1c7978c66ec410e3db Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 25 Mar 2024 08:08:58 +0100 Subject: QDebug: fix copy-instead-of-move issues Coverity correctly complains that we're copying the QDebug object when calling print*Container() when we could have moved it into the helper. So do move it. Coverity-Id: 406803 Coverity-Id: 407406 Coverity-Id: 408523 Coverity-Id: 408562 Coverity-Id: 418431 Coverity-Id: 424788 Coverity-Id: 425106 Coverity-Id: 426537 Coverity-Id: 427163 Coverity-Id: 428925 Coverity-Id: 444463 Change-Id: Ic80247f315a09fffe9363577dff1d1c781859304 Reviewed-by: Giuseppe D'Angelo (cherry picked from commit 7e8196510df88bc956492593c27da1af7b31b8ef) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit aecc4b1aba48636568043b985eeb72023b8a9e0e) --- src/corelib/io/qdebug.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 11900145fa0..02bbc7759f7 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -283,67 +283,67 @@ using QDebugIfHasDebugStreamContainer = template inline QDebugIfHasDebugStreamContainer, T> operator<<(QDebug debug, const QList &vec) { - return QtPrivate::printSequentialContainer(debug, "QList", vec); + return QtPrivate::printSequentialContainer(std::move(debug), "QList", vec); } template inline QDebugIfHasDebugStream operator<<(QDebug debug, const QVarLengthArray &vec) { - return QtPrivate::printSequentialContainer(debug, "QVarLengthArray", vec); + return QtPrivate::printSequentialContainer(std::move(debug), "QVarLengthArray", vec); } template inline QDebugIfHasDebugStream operator<<(QDebug debug, const std::vector &vec) { - return QtPrivate::printSequentialContainer(debug, "std::vector", vec); + return QtPrivate::printSequentialContainer(std::move(debug), "std::vector", vec); } template inline QDebugIfHasDebugStream operator<<(QDebug debug, const std::list &vec) { - return QtPrivate::printSequentialContainer(debug, "std::list", vec); + return QtPrivate::printSequentialContainer(std::move(debug), "std::list", vec); } template inline QDebugIfHasDebugStream operator<<(QDebug debug, std::initializer_list list) { - return QtPrivate::printSequentialContainer(debug, "std::initializer_list", list); + return QtPrivate::printSequentialContainer(std::move(debug), "std::initializer_list", list); } template inline QDebugIfHasDebugStream operator<<(QDebug debug, const std::map &map) { - return QtPrivate::printSequentialContainer(debug, "std::map", map); // yes, sequential: *it is std::pair + return QtPrivate::printSequentialContainer(std::move(debug), "std::map", map); // yes, sequential: *it is std::pair } template inline QDebugIfHasDebugStream operator<<(QDebug debug, const std::multimap &map) { - return QtPrivate::printSequentialContainer(debug, "std::multimap", map); // yes, sequential: *it is std::pair + return QtPrivate::printSequentialContainer(std::move(debug), "std::multimap", map); // yes, sequential: *it is std::pair } template inline QDebugIfHasDebugStreamContainer, Key, T> operator<<(QDebug debug, const QMap &map) { - return QtPrivate::printAssociativeContainer(debug, "QMap", map); + return QtPrivate::printAssociativeContainer(std::move(debug), "QMap", map); } template inline QDebugIfHasDebugStreamContainer, Key, T> operator<<(QDebug debug, const QMultiMap &map) { - return QtPrivate::printAssociativeContainer(debug, "QMultiMap", map); + return QtPrivate::printAssociativeContainer(std::move(debug), "QMultiMap", map); } template inline QDebugIfHasDebugStreamContainer, Key, T> operator<<(QDebug debug, const QHash &hash) { - return QtPrivate::printAssociativeContainer(debug, "QHash", hash); + return QtPrivate::printAssociativeContainer(std::move(debug), "QHash", hash); } template inline QDebugIfHasDebugStreamContainer, Key, T> operator<<(QDebug debug, const QMultiHash &hash) { - return QtPrivate::printAssociativeContainer(debug, "QMultiHash", hash); + return QtPrivate::printAssociativeContainer(std::move(debug), "QMultiHash", hash); } template @@ -357,7 +357,7 @@ inline QDebugIfHasDebugStream operator<<(QDebug debug, const std::pair inline QDebugIfHasDebugStreamContainer, T> operator<<(QDebug debug, const QSet &set) { - return QtPrivate::printSequentialContainer(debug, "QSet", set); + return QtPrivate::printSequentialContainer(std::move(debug), "QSet", set); } template -- cgit v1.2.3 From 47dd5b7aed6ccc623b3c08f74ed89112be112ec4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 15 Feb 2024 15:04:18 -0800 Subject: QXmlStreamWriter: decode UTF-8 into code points We were iterating over code *units* and that yielded wrong results. The one from the bug report was simply caused by the fact that QUtf8StringView::value_type is char, which is signed on x86, so the expression: *it <= u'\x1F' was true for all non-Latin1 content. But in attempting to fix this, I needed to do the proper UTF-8 decoding, as otherwise we wouldn't catch non-Latin1 sequences and such. [ChangeLog][QtCore][QXmlStreamWriter] Fixed a bug that caused the class to fail to write UTF-8 strings with non-US-ASCII content when passed as a QUtf8StringView. Fixes: QTBUG-122241 Change-Id: I83dda2d36c904517b3c0fffd17b42bbf09a493d0 Reviewed-by: Mate Barany (cherry picked from commit 94c62e322264e2e7d61193ae74ba8556a330385c) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 6bef40cb821bcaa0df62c17b7e6d19e95c9cea21) --- src/corelib/serialization/qxmlstream.cpp | 46 +++++++++++++++++++++++++------- src/corelib/text/qstringconverter_p.h | 9 +++++++ 2 files changed, 45 insertions(+), 10 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index f34929bfa2d..15d9d6ba3b2 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -2981,54 +2981,80 @@ void QXmlStreamWriterPrivate::write(QAnyStringView s) void QXmlStreamWriterPrivate::writeEscaped(QAnyStringView s, bool escapeWhitespace) { + struct NextLatin1 { + char32_t operator()(const char *&it, const char *) const + { return uchar(*it++); } + }; + struct NextUtf8 { + char32_t operator()(const char *&it, const char *end) const + { + uchar uc = *it++; + char32_t utf32 = 0; + char32_t *output = &utf32; + qsizetype n = QUtf8Functions::fromUtf8(uc, output, it, end); + return n < 0 ? 0 : utf32; + } + }; + struct NextUtf16 { + char32_t operator()(const QChar *&it, const QChar *) const + { + return (it++)->unicode(); + } + }; + QString escaped; escaped.reserve(s.size()); s.visit([&] (auto s) { using View = decltype(s); + using Decoder = std::conditional_t, NextLatin1, + std::conditional_t, NextUtf8, NextUtf16>>; auto it = s.begin(); const auto end = s.end(); + Decoder decoder; while (it != end) { QLatin1StringView replacement; auto mark = it; while (it != end) { - if (*it == u'<') { + auto next_it = it; + char32_t uc = decoder(next_it, end); + if (uc == u'<') { replacement = "<"_L1; break; - } else if (*it == u'>') { + } else if (uc == u'>') { replacement = ">"_L1; break; - } else if (*it == u'&') { + } else if (uc == u'&') { replacement = "&"_L1; break; - } else if (*it == u'\"') { + } else if (uc == u'\"') { replacement = """_L1; break; - } else if (*it == u'\t') { + } else if (uc == u'\t') { if (escapeWhitespace) { replacement = " "_L1; break; } - } else if (*it == u'\n') { + } else if (uc == u'\n') { if (escapeWhitespace) { replacement = " "_L1; break; } - } else if (*it == u'\v' || *it == u'\f') { + } else if (uc == u'\v' || uc == u'\f') { hasEncodingError = true; break; - } else if (*it == u'\r') { + } else if (uc == u'\r') { if (escapeWhitespace) { replacement = " "_L1; break; } - } else if (*it <= u'\x1F' || *it >= u'\uFFFE') { + } else if (uc <= u'\x1F' || uc == u'\uFFFE' || uc == u'\uFFFF') { hasEncodingError = true; break; } - ++it; + it = next_it; } escaped.append(View{mark, it}); diff --git a/src/corelib/text/qstringconverter_p.h b/src/corelib/text/qstringconverter_p.h index 9b633a8f7e1..f1fe50da971 100644 --- a/src/corelib/text/qstringconverter_p.h +++ b/src/corelib/text/qstringconverter_p.h @@ -43,18 +43,27 @@ struct QUtf8BaseTraits static void appendByte(qchar8_t *&ptr, qchar8_t b) { *ptr++ = b; } + static uchar peekByte(const char *ptr, qsizetype n = 0) + { return ptr[n]; } + static uchar peekByte(const uchar *ptr, qsizetype n = 0) { return ptr[n]; } static uchar peekByte(const qchar8_t *ptr, qsizetype n = 0) { return ptr[n]; } + static qptrdiff availableBytes(const char *ptr, const char *end) + { return end - ptr; } + static qptrdiff availableBytes(const uchar *ptr, const uchar *end) { return end - ptr; } static qptrdiff availableBytes(const qchar8_t *ptr, const qchar8_t *end) { return end - ptr; } + static void advanceByte(const char *&ptr, qsizetype n = 1) + { ptr += n; } + static void advanceByte(const uchar *&ptr, qsizetype n = 1) { ptr += n; } -- cgit v1.2.3 From 5d727ab430e215cac45af3b09d0e99199aeb040c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 29 Apr 2024 10:20:59 +0200 Subject: QSettings/removed_api: don't return Fixes clazy-returning-void-expression. Amends 4cf299eb5bbdbac8484c2ee8c5afbd260dccc6d5. Change-Id: I6192deb82afe9a5ba7ddaf6203d4046f518c545a Reviewed-by: Ivan Solovev (cherry picked from commit 59d24e361538e8ea03adc12785cbb73ecba61ab2) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 2ca66ab096e4464a000101c83d8a01f642ccf70e) --- src/corelib/compat/removed_api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index 948d7168e89..634fe8e760c 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -200,7 +200,7 @@ void QObject::setObjectName(const QString &name) void QSettings::beginGroup(const QString &prefix) { - return beginGroup(qToAnyStringViewIgnoringNull(prefix)); + beginGroup(qToAnyStringViewIgnoringNull(prefix)); } int QSettings::beginReadArray(const QString &prefix) -- cgit v1.2.3 From 1ba9a1fec86fe4eb8468e110a34db9a51d1a1f55 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Thu, 1 Feb 2024 11:50:25 +0100 Subject: QDataStream::readBytes(): make the growth of the buffer geometric The algorithm tries to allocate the memory using 1 Mb blocks. When the input data is large, this results in a lot of reallocations, which is slow and inefficient. This patch modifies the algorithm in such way that the allocation size increases at each step, resulting in geometric growth of the buffer. As all the variables in the algorithm are quint32, and the blockSize is int, we need to make sure that it does not become negative, because readBlock() is not designed to handle negative length. Note that we cannot simply "fix" the problem by converting blockSize to quint32, because that will just postpone quint32 -> int conversion until the function call. So, add an extra check to make sure that the value does not exceed INT_MAX. Change-Id: I071df68d51ba1dbd8b2eb5f94eb078a33223505f Reviewed-by: Thiago Macieira (cherry picked from commit a1bfac287ee5d3719646d68dc91dc8e8e4cec04e) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 44dc38ebc9fa407565ec1699bdbb1f97ffd13f1c) Reviewed-by: Marc Mutz --- src/corelib/serialization/qdatastream.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/serialization/qdatastream.cpp b/src/corelib/serialization/qdatastream.cpp index 6319269d41f..4d728f61a57 100644 --- a/src/corelib/serialization/qdatastream.cpp +++ b/src/corelib/serialization/qdatastream.cpp @@ -1056,13 +1056,15 @@ QDataStream &QDataStream::readBytes(char *&s, uint &l) if (len == 0) return *this; - const quint32 Step = 1024 * 1024; + quint32 step = 1024 * 1024; quint32 allocated = 0; char *prevBuf = nullptr; char *curBuf = nullptr; + constexpr quint32 MaxBlockSize = std::numeric_limits::max(); do { - int blockSize = qMin(Step, len - allocated); + const quint32 sz = qMin(step, len - allocated); + int blockSize = qMin(sz, MaxBlockSize); prevBuf = curBuf; curBuf = new char[allocated + blockSize + 1]; if (prevBuf) { @@ -1074,6 +1076,7 @@ QDataStream &QDataStream::readBytes(char *&s, uint &l) return *this; } allocated += blockSize; + step *= 2; } while (allocated < len); s = curBuf; -- cgit v1.2.3 From ac21796c2f0859414f3a71e03622e92ba8d603f6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 8 Feb 2024 11:36:57 +0100 Subject: QList: give the LWG 3346 #ifdef'ery a symbolic name We'll need this in more places, so centralize its definition in qcompilerdetection.h. Amends 595b4e1a9b436a8190964dc41f79621400f5a6be. Change-Id: I87f84cb9ff3ad339c000604423295180176f5799 Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit f4cfc21dec6319c2ae99042be6bb12922a9d336d) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit bfd565a4d300b4227b09fa1e52c18778d997d96c) (cherry picked from commit 0c8e26bbfc5cf58854124ca1f9082aa4c1dbc065) --- src/corelib/global/qcompilerdetection.h | 5 +++++ src/corelib/tools/qlist.h | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index a3a60bc15d6..0e21c7d6e66 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1370,6 +1370,11 @@ QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantic # endif #endif +// libstdc++ shipped with gcc < 11 does not have a fix for defect LWG 3346 +#if __cplusplus >= 202002L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 11) +# define QT_COMPILER_HAS_LWG3346 +#endif + #endif // __cplusplus #endif // QCOMPILERDETECTION_H diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 3742b8bcfb5..5cc71f828d5 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -109,8 +109,7 @@ public: public: using difference_type = qsizetype; using value_type = T; - // libstdc++ shipped with gcc < 11 does not have a fix for defect LWG 3346 -#if __cplusplus >= 202002L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 11) +#ifdef QT_COMPILER_HAS_LWG3346 using iterator_concept = std::contiguous_iterator_tag; using element_type = value_type; #endif @@ -180,8 +179,7 @@ public: public: using difference_type = qsizetype; using value_type = T; - // libstdc++ shipped with gcc < 11 does not have a fix for defect LWG 3346 -#if __cplusplus >= 202002L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 11) +#ifdef QT_COMPILER_HAS_LWG3346 using iterator_concept = std::contiguous_iterator_tag; using element_type = const value_type; #endif -- cgit v1.2.3 From 72e405b9079707c9c033864aa66d20221b54bb06 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 18 Apr 2024 10:25:21 +0200 Subject: QStringConverterICU: Pass correct pointer to callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass the pointer to the current state, not a pointer to a pointer to it. [ChangeLog][QtCore][QStringConverter] Fixed a bug involving moved QStringEncoder/QStringDecoder objects accessing invalid state. Amends 122270d6bea164e6df4357f4d4d77aacfa430470. Done-with: Marc Mutz Change-Id: I70d4dc00e3e0db6cad964579662bcf6d185a4c34 Reviewed-by: Fabian Kosmale Reviewed-by: Mårten Nordheim (cherry picked from commit 39bbfce9b675c9085ef49c9b9c52c146eca55e4a) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 7c4e1357e49baebdd2d20710fccb5604cbb36c0d) --- src/corelib/text/qstringconverter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index 6ca65ba6ad8..043b8f54151 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -1966,7 +1966,7 @@ struct QStringConverterICU : QStringConverter const void *context; ucnv_getToUCallBack(icu_conv, &action, &context); if (context != state) - ucnv_setToUCallBack(icu_conv, action, &state, nullptr, nullptr, &err); + ucnv_setToUCallBack(icu_conv, action, state, nullptr, nullptr, &err); ucnv_toUnicode(icu_conv, &target, targetLimit, &source, sourceLimit, nullptr, flush, &err); // We did reserve enough space: @@ -1999,7 +1999,7 @@ struct QStringConverterICU : QStringConverter const void *context; ucnv_getFromUCallBack(icu_conv, &action, &context); if (context != state) - ucnv_setFromUCallBack(icu_conv, action, &state, nullptr, nullptr, &err); + ucnv_setFromUCallBack(icu_conv, action, state, nullptr, nullptr, &err); ucnv_fromUnicode(icu_conv, &target, targetLimit, &source, sourceLimit, nullptr, flush, &err); // We did reserve enough space: -- cgit v1.2.3 From 5d8e9a8415562ba004b38508d91e1fa0254c17d3 Mon Sep 17 00:00:00 2001 From: Tarja Sundqvist Date: Fri, 30 May 2025 16:52:30 +0300 Subject: Revert "Update commercial SPDX-License-Identifier" This reverts commit 4c16c8afb37f0b4cbcfb37d47baf6fc29e42c7b7. The revert is needed for the opensource releases which cannot contain commercial license headers. Change-Id: I0caa255093ecf406978de958cd3810bc9f80121e Reviewed-by: Jani Heikkinen --- src/corelib/debug_script.py | 2 +- src/corelib/mimetypes/mime/hexdump.ps1 | 2 +- src/corelib/tools/quniquehandle_p.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/debug_script.py b/src/corelib/debug_script.py index 6dee5961524..f6207c6104e 100644 --- a/src/corelib/debug_script.py +++ b/src/corelib/debug_script.py @@ -1,5 +1,5 @@ # Copyright (C) 2017 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/src/corelib/mimetypes/mime/hexdump.ps1 b/src/corelib/mimetypes/mime/hexdump.ps1 index 01d386fa821..26fb9dd6e65 100644 --- a/src/corelib/mimetypes/mime/hexdump.ps1 +++ b/src/corelib/mimetypes/mime/hexdump.ps1 @@ -1,5 +1,5 @@ # Copyright (C) 2019 Intel Corporation. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 param([String]$path, [String]$orig) diff --git a/src/corelib/tools/quniquehandle_p.h b/src/corelib/tools/quniquehandle_p.h index e31699a1229..7af1536c2ed 100644 --- a/src/corelib/tools/quniquehandle_p.h +++ b/src/corelib/tools/quniquehandle_p.h @@ -1,5 +1,5 @@ // Copyright (C) 2023 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QUNIQUEHANDLE_P_H #define QUNIQUEHANDLE_P_H -- cgit v1.2.3