summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
* Move qt_error_string to qlogging.hSona Kurazyan2022-08-051-0/+1
| | | | | | | | | | qcontainerfwd.h was relying on the forward declaration of QString in qglobal.h, so add the missing forward declaration there. Task-number: QTBUG-99313 Change-Id: Id3ecaed5ce3b64dabb8454647a43d1520d30e713 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QVariant: make many more QtCore types nothrow-copyableThiago Macieira2022-07-302-4/+4
| | | | | | | | | | | | | | | All of those are implicitly-shared Qt data types whose copy constructors can't throw and have wide contracts (there aren't even any assertions for validity in any of them). These are all types with a QVariant implicit constructor, except for QCborValue, which is updated on this list so QJsonValue (which has a QVariant constructor) is also legitimately noexcept. To ensure we haven't made a mistake, the Private constructor checks again. Change-Id: I3859764fed084846bcb0fffd17044d8319a45e1f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Extract header qenvironmentvariables.h from qglobal.hSona Kurazyan2022-07-291-0/+1
| | | | | | | | | | | | | qcontainerfwd.h was relying on the forward declaration of QByteArray in qglobal.h, so add the missing forward declaration there. Additionally, had to move the implementations of qTzSet() and qMkTime() to qenvironmentvariables.cpp along with environmentMutex. Task-number: QTBUG-99313 Change-Id: I233aff305c2fedaf0a48362cc99ff2d6f6c0ee54 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Doc: Add default value for seed param to all qHash overloadsKai Köhne2022-07-203-4/+2
| | | | | | Pick-to: 6.4 Change-Id: I4d559ccd60ec54d2584dceecaece7e0899c0eea9 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtBase: eradicate QT_STRINGVIEW_LEVEL usesMarc Mutz2022-07-201-2/+0
| | | | | | | | | | | | It's not used and not useful. The macro itself has to stay, for now, because Qt5Compat uses it, too. Task-number: QTBUG-100861 Pick-to: 6.4 6.3 6.2 Change-Id: I5d0557a6c959d6facf6e47f26786a9d365339e95 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Long live QT6_{DECL,IMPL,CALL}_NEW_OVERLOAD!Marc Mutz2022-07-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have in the past found ourselves in need of disambiguating new overloads from older, QT_REMOVED_SINCE'ed ones, which we usually did by adding a defaulted int argument, cf. e.g. QMetaType::id(). The problem with a defaulted int argument is twofold: First, an int is a valid argument type, and users may get confused as to its meaning when presented with the signature in the IDEs auto-completion popup, and a lot of things implicitly convert to an int, so any errornous parameter passing may stay unnoticed until we remove these fake arguments come Qt 7. Second, this way of doing things requires a lot of ifdef'ery to keep the additional argument out of both the docs and future Qt 7 builds. The solution presented in this patch is to create a tag type, QDisambiguated_t, which a) more clearly communicates its purpose and b) doesn't implicitly convert from anything. To help with the invariably ugly ifdef'ery, provide a set of macros that hide this stuff from qdoc and Qt 7 builds. Use the macros to replace the fake int arguments that were added for 6.4. Pick-to: 6.4 Change-Id: I6916f38c8eb9793ad6dea5f61e7e5fff7e75e273 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLine/F: mark as primitive typeMarc Mutz2022-07-081-2/+2
| | | | | | | | | | QPoint/F are, then so are QLine/F, being a pair of points. Found by static_assert()ing !isComplex in QDataBuffer. Pick-to: 6.4 Change-Id: I358a38d79820c9262a86018253002bc991c5a6e4 Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
* Add the qt_class pragma to file listed in sync.profile classnames mapAlexey Edelev2022-06-222-0/+8
| | | | | | | | | This makes header files self-contained and reduces the number of 'sources of truth' for syncqt procedure. Change-Id: I7f5865abc69934603139d23e1b5452da46ccb110 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qHash: pass QByteArrayView to qHash() by valueThiago Macieira2022-06-152-6/+9
| | | | | | | | | | | | | The QBAV one should pass the parameter by value, like QStringView. And now that we have it, the non-View one should call the View one in an inline function, like we already do for QString. The extra, defaulted parameter is there only so we get a different signature in the new inline function compared to the removed one. Pick-to: 6.4 Change-Id: If05aeeb7176e4f13af9afffd16e7f08062b1dc86 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add "We mean it" warning to new private headerVolker Hilsheimer2022-06-131-0/+11
| | | | | | | | Amends 5e48a51608485cbc87b68498fd54ab36f001d584, fixing warning from syncqt. Change-Id: I15d22a1bba865777c17180438b6e89ee9e1ae78b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Long live QAtomicScopedValueRollback (private API)!Marc Mutz2022-05-311-0/+95
| | | | | | | | | | | | | | | | | | | | | | | | | QScopedValueRollback has a few users that apply it on QAtomicInt, which happens to work as QAtomicInt is copy-constructible and its ctors are implicit. But that's of course nonsense. We don't need to store the oldValue in an atomic, nor do we need to pass the new value into the ctor as an atomic. So, add a QAtomicScopedValueRollback which works on std::atomic as well as the Qt atomics, but distinguishes between the reference (which is atomic) and the value (which isn't), and use it in one of the users, tst_QList. Keep it private until we know whether there's an actual need for this. The test is a copy of tst_qscopedvaluefallback, so the occasional oddity (like atomic op*=) should be ignored. Task-number: QTBUG-103835 Change-Id: I3c05b3e51f465698657a02ca5521ed465386e9a6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMap: remove more docs referring to multiple values for the same keyGiuseppe D'Angelo2022-05-291-21/+4
| | | | | | | | Such semantics have been dropped from Qt 6. Change-Id: I12f3478833afafa34f9075faf9ed030d06cd86f9 Pick-to: 6.2 6.3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMap: fix values() documentationGiuseppe D'Angelo2022-05-251-3/+1
| | | | | | | | | The body was still referring to the Qt 5 QMap where the same key could be mapping to multiple values. That's no longer the case in Qt 6. Change-Id: Idb1786ac45f328c318878fa52bf5d43d79c0178a Pick-to: 6.2 6.3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QVector: make sure the forwarding headers for the Java iterators existThiago Macieira2022-05-231-0/+6
| | | | | | | | | | | | | | They used to in Qt 5. And now they do again: $ grep . include/QtCore/Q*Vector* include/QtCore/QMutableVectorIterator:#include "qvector.h" include/QtCore/QVector:#include "qvector.h" include/QtCore/QVectorIterator:#include "qvector.h" Pick-to: 6.2 6.3 Fixes: QTBUG-103742 Change-Id: I77c8221eb2824c369feffffd16f128a983f4866c Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-1684-3117/+201
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QVersionNumber: de-inline QList constructor calls and resize()Marc Mutz2022-05-132-12/+36
| | | | | | | | | | | | | | | | | | | The QList<int> range ctor and other QList<int> methods have percolated up near the top of the list of Clang -ftime-trace most expensive template instantiations in PCH libQt6Gui.so builds: **** Templates that took longest to instantiate: [...] 5138 ms: QList<int>::QList<const int *, true> (256 times, avg 20 ms) 4327 ms: QtPrivate::QCommonArrayOps<int>::appendIteratorRange<const int *> (256 times, avg 16 ms) The code in 6.3 is already sufficiently different for this patch to not be applicable there. Task-number: QTBUG-97601 Change-Id: I4420c8c90e472ecfd679b414cc4334d2ab55cce3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVarLengthArray: Move unique_ptr<void, free_deleter> to QVLABaseBaseMarc Mutz2022-05-131-4/+6
| | | | | | | | | | | | | | | | | This avoids repeated re-instantiations of unique_ptr with local deleters, removing that instantiation from the top of the list in Clang -ftime-trace QtWidgets builds: **** Templates that took longest to instantiate: 2627 ms: std::__1::unique_ptr<void, free_deleter> (835 times, avg 3 ms) Amends e297e80fd0ec6ce4c97ee1b40426c76377b45ecc. Pick-to: 6.3 Task-number: QTBUG-97601 Task-number: QTBUG-99039 Change-Id: I1281f6cf9248a3796d9dfdc653f19f5a67dc3bda Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove remnants of the old Intel C++ compilerThiago Macieira2022-05-111-1/+1
| | | | | | | | | | | | | We don't support it any more. I don't think it has ever properly compiled Qt 6 (and it's no longer working for me against GCC 12's libstdc++ headers). If you report a bug against it, Intel support's first question is if you can try instead the new Clang/LLVM-based oneAPI C++ compiler. So we support only that one, which identifies itself as Q_CC_CLANG. Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb57a092c8439e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QHash: port away from std::aligned_storageMarc Mutz2022-05-071-1/+1
| | | | | | | | | | | It's deprecated in C++23. Just use an explicitly-aligned char array directly, wrapped in a struct to avoid decays to char*. Task-number: QTBUG-99122 Pick-to: 6.3 6.2 Change-Id: I802761c1af62efa6ffc006b07837a7deed1ea4cc Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use Q_CC_{GNU,MSVC}_ONLY when comparing to particular versionsMarc Mutz2022-05-062-3/+3
| | | | | | | | | | | | | | | | | This prevents false-negatives and false-positives, as e.g. Clang 10.0.0 masks as GCC 4.2, so Q_CC_GNU is 402 on that compiler. Depending on the test (Q_CC_GNU > NNN or Q_CC_GNU < NNN), the result of the test is almost random. Q_CC_<comp>_ONLY makes sure we match only GCC or MSVC, not bycatch such as Clang or ICC. Pick-to: 6.3 6.2 5.15 Change-Id: I4c550a11ecf85fc9a2216b330b69bd03d45b47e0 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QVersionNumber: Show type in QDebug outputFlorian Bruhin2022-05-041-1/+2
| | | | | | | | | | | To make it clearer what kind of object is being printed, and also more consistent with the QDebug output of other classes. Fixes: QTBUG-103085 Pick-to: 6.3 Change-Id: Ia7441dd373d359be2a87ec618684d27375a1dcf8 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qhashfunctions.h: add std::hash specialization for QByteArrayViewThiago Macieira2022-04-221-0/+1
| | | | | | | | [ChangeLog][QtCore][QByteArrayView] Added std::hash specialization. Change-Id: If05aeeb7176e4f13af9afffd16e7f03dfa413a66 Reviewed-by: Rui Oliveira Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QVarLengthArray: add missing (size, value) ctorMarc Mutz2022-04-132-0/+21
| | | | | | | | | | | Extend the corresponding test in tst_containerapisymmetry. [ChangeLog][QtCore][QVarLengthArray] Added (size, value) constructor. Fixes: QTBUG-102469 Change-Id: I4802eebe6ba1a6835e4d6f41e1d3db2a0d7c7894 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVarLengthArray: simplify SFINAE on resize(n, v)Marc Mutz2022-04-131-6/+6
| | | | | | | | | | | | Use our usual if_x<> = true pattern to move the constraint to where it belongs (absent C++20 requires-clauses): into the template argument list. Amends a00a1d8806cfbf17e04b88d1b4ff4a9cf5b6294a. Change-Id: I846b96bdeec3def221346897181d3d4d3a55316d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Q[Multi]Hash: fix squeeze()Ivan Solovev2022-04-061-15/+29
| | | | | | | | | | | | | | | | | | | When calling QHash::reserve(), or when creating the internal QHashPrivate::Data structure, the value 0 for the size parameter is reserved for performing the squeeze operation. However commit 8a984ab772dd194e39094e728b869e65912912a7 broke it, by using the 0 value in QHashPrivate::Data constructors as a mark that no resizing needs to be done. This patch reverts the problematic commit (also applying some later fixes to the code), and adds the missing tests for Q[Multi]Hash::squeeze(). Pick-to: 6.3 6.2 Change-Id: Id644df7b2beb008e6a37b2c89b709adfbd893e25 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Q[Multi]Hash::reserve(): do nothing if desired size is less than currentIvan Solovev2022-04-061-0/+6
| | | | | | | | | | | | | | | | Calling Q[Multi]Hash::reserve(n) when n is much smaller than the current amount of elements in the hash, could result in an infinite loop, because at some point the algorithm could not find a free bucket for the element. Fixing it by returning early if the new desired capacity is less than current. Fixes: QTBUG-102067 Pick-to: 6.3 6.2 Change-Id: I38ef0b2168c4e2a317eedf91b2155b1fdffb1c27 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QByteArray/QVarLengthArray: add missing resize(n, v) overloadsMarc Mutz2022-04-062-5/+35
| | | | | | | | | | | | | | | | | | QList and QString had them, so add them to QByteArray and QVarLengthArray, too. In the QVLA case, we need to jump though a hoop or two to avoid having to duplicate all the reallocation logic. Nothing a few template tricks cannot solve. [ChangeLog][QtCore][QByteArray] Added resize(n, ch) overload. [ChangeLog][QtCore][QVarLengthArray] Added resize(n, v) overload. Fixes: QTBUG-102270 Change-Id: I0d281ae5b574f440f682e4a62427b434dcf5b687 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: QMap: Add ref-qualifiers to \fn signatures for toStd[Multi]Map()Topi Reinio2022-03-312-2/+2
| | | | | | | | | | Because of a bug in QDoc there was never a warning reported for the missing qualifiers. Pick-to: 6.3 Task-number: QTBUG-101461 Change-Id: Ibb9114bc5d29e75158d2ac254169ba2a73043f0d Reviewed-by: Luca Di Sera <luca.disera@qt.io>
* Apply Q_CONSTINIT across the codebaseMarc Mutz2022-03-293-7/+9
| | | | | | | | | Still not complete. Just grepping for static and thread_local. Task-number: QTBUG-100486 Change-Id: I90ca14e8db3a95590ecde5f89924cf6fcc9755a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: Replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-03-265-10/+10
| | | | | | | Task-number: QTBUG-98434 Change-Id: Ib7c5fc0aaca6ef33b93c7486e99502c555bf20bc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtCore: replace QLatin1String/QLatin1Char with _L1/u'' where applicableSona Kurazyan2022-03-253-14/+16
| | | | | | | | | | | As a drive-by, did also minor refactorings/improvements. Task-number: QTBUG-98434 Change-Id: I81964176ae2f07ea63674c96f47f9c6aa046854f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* Fix build with latest Apple clang versionVolker Hilsheimer2022-03-211-2/+2
| | | | | | | | | | | | | | | | | | Building with Apple clang 13.1.6.13160021 (from command line tools 13.3) results in qhash.cpp:754:39: error: passing 16-byte aligned argument to 32-byte aligned parameter 3 of 'operator()' may result in an unaligned pointer access [-Werror,-Walign-mismatch] hash2x32bytes(state0, state1, src, src + 1); ^ Help the compiler with deducing the right type for 'src' and 'srcend'. Also makes 'src' const explicitly. Change-Id: Id14a034f0fa4c2a002d9b37729d803a50a0e5e9c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRect: add toRectF()Marc Mutz2022-03-192-4/+24
| | | | | | | | | | For symmetry with QRectF::toRect(). [ChangeLog][QtCore][QRect] Added toRectF(). Fixes: QTBUG-73160 Change-Id: If2bda64b8fe4bc113191dda927e9bb86ebcb4c69 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLine/QMargins: add toLineF/toMarginsF()Marc Mutz2022-03-194-7/+38
| | | | | | | | | | | | | For symmetry with QLineF::toLine(). [ChangeLog][QtCore][QLine] Added toLineF(). [ChangeLog][QtCore][QMargins] Added toMarginsF(). Task-number: QTBUG-73160 Change-Id: I69051cdd2fe4a3c0a000ab86e363a2918a7aea7c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QSize/QPoint: add toSizeF/toPointF()Marc Mutz2022-03-194-8/+36
| | | | | | | | | | | | | For symmetry with QSizeF::toSize(). [ChangeLog][QtCore][QSize] Added toSizeF(). [ChangeLog][QtCore][QPoint] Added toPointF(). Task-number: QTBUG-73160 Change-Id: I65b088b4f7365ab671ef2f0c75821b707f5ac26d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QMargins: fix a missing "full stop" in the docsMarc Mutz2022-03-191-1/+1
| | | | | | Pick-to: 6.3 6.2 5.15 Change-Id: Ic8012ce12ef8d2fee2dc785e373e9c9d8f658ff5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVariant: reduce transitive includesFabian Kosmale2022-03-171-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Forward declare more types in qvariant.h, and do the same for qdebug.h (which will be removed from qvariant in a separate patch). As we now only forward declare containers (e.g. QMap, QList, ...), code which includes <QVariantMap>, <QVariantList>... breaks without further adjustment: So far, those headers simply included qvariant.h. However, by introducing new actual headers for those types and adjusting sync.profile, we can avoid this issue. To avoid breaking leaf modules and user code, we make the change opt-in: Unless QT_LEAN_HEADERS is defined to a value of >= 1, we still include the superfluous headers. We also set this macro in qtbase via QT_EXTRA_INTERNAL_TARGET_DEFINES. [ChangeLog][Potentially Source-Incompatible Changes] qvariant.h no longer includes <QList>, <QMap>, <QHash>, <QVarLengthArray>, <QSet> and <QObject>. Code that relied on transitive includes might need to explicitly include those headers now. Notably, including <QVariant> (or qvariant.h) is no longer sufficient when using QVariant(List|Map|Hash). Using them now requires including respectively <QVariantList>, <QVariantMap>, or <QVariantHash>. Alternatively, including <QVariant> and the <QList>, <QMap> or <QHash> header also works. [ChangeLog][Potentially Source-Incompatible Changes] qdebug.h no longer includes <QSet>, <QHash>, <QVarLengthArray> and <QMap>. Code that relied on transitive includes might need to explicitly include those headers now. Task-number: QTBUG-97601 Change-Id: I142e5de709ed0b305716369a3266389ab7fbbb71 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Core: Do not depend on transitive includesFabian Kosmale2022-03-171-0/+1
| | | | | Change-Id: I2c71188a4d27692a2d6ef1aa447b329627214b17 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QHash: fix -Werror=maybe-uninitialized (GCC 11.2)Marc Mutz2022-03-171-1/+1
| | | | | | | | | | | | | | | | The compiler doesn't understand understand that the only way ok can be true is for qstrntoll() to have been executed. qhash.cpp:158:9: error: ‘seed’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 158 | if (seed) { | ^~ Help poor GCC by initializing the variable unconditionally. Amends cc5cc3225d6a397270a6d4c615e850e43db805c4. Change-Id: Ic8387e0add2291d994f7f4d96c4bc614b2a8aa99 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFlatMap: make insertion STL-compatibleMarc Mutz2022-03-161-23/+51
| | | | | | | | | | | | | | | | | | | | | | That is, insert() doesn't overwrite an existing entry, and range insert inserts the first of equivalent keys' values, not the last. This allowed this author to optimize the implementation of makeUnique() to a O(N) algorithm (was: O(N²)). Said optimization would have been possible with the old semantics, too, but I wrote the algorithm first and only then noticed the broken insert() behavior is present on QFlatMap, too, so I decided not to let good code go to waste and to fix both problems at the same time. In order to give users a hint of the changed semantics, make the new API opt-in until Qt 6.5, so Qt 6.4 ships with the both the old and the new semantics disabled, where they contradict. Fixes: QTBUG-100092 Change-Id: Ic96d8bfe6bed9068dbe8c0d7171bd8921050fd95 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QHash: Initialize the hash seed as soon as QtCore loadsThiago Macieira2022-03-151-11/+31
| | | | | | | | | | | | | | | | | | | | Instead of lazily initializing (with some platform exceptions, see the equivalent qsimd.cpp commit). The rationale is the same as for qCpuFeatures(): this the qHashBits() function is hot and the current code generation needs to save a lot of state because of the possible call to the C++ runtime functions to enable the thread-safe initialization of the hash seed. [ChangeLog][Important Behavior Changes] QtCore now initializes the QHash global seed before the main() function is run, so it is no longer possible to use qputenv() to affect the seed value for the current process. Disabling the random global seed for the current process should be done programmatically with by calling either the 6.2 function QHashSeed::setDeterministicGlobalSeed() or, if compatibility with Qt 5 is required, by calling qSetGlobalQHashSeed() with value 0. Change-Id: I54f205f6b7314351b078fffd16cf7eae93f9e27e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QVersionNumber: Make documentation period display style consistentChristian Heimlich2022-03-151-1/+1
| | | | | | | | | | | | | | | | | | In the current documentation for this class there are two ways that the period character is referred to. Code Style: https://doc.qt.io/qt-6/qversionnumber.html#fromString Quote Style: https://doc.qt.io/qt-6/qversionnumber.html#fromString-1 The code-style version is significantly clearer and clean looking, while the quote-style version is easy to misinterpret, especially when followed by an additional period at the end of a sentence. This change updates the documentation so that the nicer style is used in all locations to improve clarity and consistency. Change-Id: I11a6d82accb923e24c00b93728ea084d27efd06d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use qstringfwd.h when forward declaring string classesSona Kurazyan2022-03-121-3/+1
| | | | | | Task-number: QTBUG-98434 Change-Id: I37b70a1b7bc164fa7dc9cb702827297ca66a6fdc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFlatMap: fix warning -Wunused-but-set-variable (GCC) in remove_if()Marc Mutz2022-03-111-1/+1
| | | | | | | | Amends 6f5c78fe3d445f1c6c8738f9cedb9dbd847645fa. Change-Id: I01a474f8ccb9de7d7b76a33a950542e38edc78e4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* CMake: add detection of x86 VAES and AVX512VBMI2 featuresThiago Macieira2022-03-081-1/+1
| | | | | | | | We have VAES code in qhash.cpp that isn't getting compiled right now. Change-Id: Ibf4acec0f166495998f7fffd16d6961261dec361 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QWeakPointer: befriend other QWeakPointersThiago Macieira2022-03-041-1/+2
| | | | | | | | | | Commit c677b3b8afcdc1d7b57353826cc01f378cd25e99 added move constructors, which introduced the issue. Pick-to: 6.2 6.3 Fixes: QTBUG-100795 Change-Id: I74249c52dc02478ba93cfffd16d2c879b923e352 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QCryptographicHash: code tidiesGiuseppe D'Angelo2022-03-041-11/+11
| | | | | | | | | | | Rename the resize() function of its internal buffer into the possibly better resizeForOverwrite(). The point is that unlike an ordinary resize the data in the buffer is NOT initialized, and therefore must be overwritten by the caller, "or else". Change-Id: I7d82821e92f59f7eeab18c51d98003826ffe164b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
* Associative containers: add a way to obtain a key/value rangeGiuseppe D'Angelo2022-03-046-0/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our associative containers' iterator's value_type isn't a destructurable type (yielding key/value). This means that something like for (auto [k, v] : map) doesn't even compile -- one can only "directly" iterate on the values. For quite some time we've had QKeyValueIterator to allow key/value iteration, but then one had to resort to a "traditional" for loop: for (auto i = map.keyValueBegin(), e = keyValueEnd(); i!=e; ++i) This can be easily packaged in an adaptor class, which is what this commmit does, thereby offering a C++17-compatible way to obtain key/value iteration over associative containers. Something possibly peculiar is the fact that the range so obtained is a range of pairs of references -- not a range of references to pairs. But that's easily explained by the fact that we have no pairs to build references to; hence, for (auto &[k, v] : map.asKeyValueRange()) doesn't compile (lvalue reference doesn't bind to prvalue pair). Instead, both of these compile: for (auto [k, v] : map.asKeyValueRange()) for (auto &&[k, v] : map.asKeyValueRange()) and in *both* cases one gets references to the keys/values in the map. If the map is non-const, the reference to the value is mutable. Last but not least, implement pinning for rvalue containers. [ChangeLog][QtCore][QMap] Added asKeyValueRange(). [ChangeLog][QtCore][QMultiMap] Added asKeyValueRange(). [ChangeLog][QtCore][QHash] Added asKeyValueRange(). [ChangeLog][QtCore][QMultiHash] Added asKeyValueRange(). Task-number: QTBUG-4615 Change-Id: Ic8506bff38b2f753494b21ab76f52e05c06ffc8b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Minor clean-ups noticed during string-parsing improvementsEdward Welbourne2022-03-031-1/+1
| | | | | | | | Simplify a conditional to save some repetition, purge some spurious parentheses. Change-Id: I727d22ce81733e765c4ee951475ccdb599063399 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QFlatMap: add remove_ifMarc Mutz2022-03-031-0/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing API of QFlatMap did not allow efficient removal of elements: - std::remove_if does not apply, because it works by moving elements back in the range onto those that need to be removed, which doesn't work in flat_map's case, because, like for all associative containers, the key in value_type is const. - The node-based erase-loop (over it = cond ? c.erase(it) : std::next(it)) works, but, unlike in traditional associative containers, is quadratic, because flat_map::erase is a linear operation. According to Stepanov's principle of Efficient Computational Basis (Elements of Programming, Section 1.4), we're therefore missing API. Add it. I couldn't make up my mind about the calling convention for the predicate and, despite having authored a merged paper about erase_if, can never remember what the predicate is supposed to take, so be fancy and accept all: (*it), (it.key(), it.value()), (it.key()). This means that unary predicates can either not be generic or must be properly constrained to distinguish between pair<const K, V> and K, but that's not necessarily a bad thing. There's no reason to supply a Qt-ified removeIf on top of the standard name, because this is private API and doubling the names would do nothing except double the testing overhead. Fixes: QTBUG-100983 Change-Id: I12545058958fc5d620baa770f92193c8de8b2d26 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>