summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
* Fix compilation for recursive Qt containersSona Kurazyan2021-09-074-14/+14
| | | | | | | | | | | | | | | | | | | | | The operator checks cause compilation errors when trying to check for their existence for recursive containers. This happens because of trying to check for the operators on the template parameter type(s), that inherit from the container itself, which leads to compilation errors. Introduced alternative versions of the operator checks (with _container suffix), that first check if the container is recursive, i.e. any of its template parameter types inherits from the given container, and skips the operator check, if that's the case. The fix is done for all Qt container types that had the problem, except for QVarLengthArray and QContiguousCache, which don't compile with recursive parameter types for unrelated reasons. Fixes: QTBUG-91707 Change-Id: Ia1e7240b4ce240c1c44f00ca680717d182df7550 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 9f13842fe61541cb8ab9822174ea963e418b5537) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Fix documentation issues for Qt CoreTopi Reinio2021-08-245-38/+56
| | | | | | | | | | | | | | | * Tag deprecated Q(Multi)Map operators in the header to correctly match them with documentation \fn commands. * Add documentation for QByteArrayView comparison operators. * Add a dummy typedef 'jfieldID' for generating docs correctly on non-Android platforms * Fix other minor issues Task-number: QTBUG-95860 Change-Id: I141d2f75d6aa10557aa374201f09ad74b4cd6e81 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 145940e1ef8fc8334ff4603a44f7896886e646cb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Add missing links to methods to QSet documentation pageLuca Di Sera2021-08-181-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Some internal links to `QSet` methods were missing from the documentation. In particular, all methods that were written with one attribute. It seems that QDoc might automatically recognize method/function links only if they have zero parameters, such that the identifier is followed by `()` directly. To avoid this problem while keeping the current parameter-containing form of the text; each function of the form `functioname(\a parametername)` was changed to `\l {functionname()} {functioname(\a parametername)}. Furthermore, one of those text instances was modified to use `\a` for the parameter name, instead of the previously used `\e`, to enhance consistency. An instance of `operator<<()` was not recognized as a link. To resolve this it was marked with the `\l` command. Fixes: QTBUG-95389 Change-Id: I16b2a7a2fbaf4785c2c6bfa5017a3db46d9db2f4 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit fd86939eaf73c5e58e12b7eb2cd0563c03d33ba9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QVarLengthArray: add missing default-ctor documentationMarc Mutz2021-08-161-0/+5
| | | | | | | | | | Was lost when we un-explicit'ed the default ctor in c34242c679aaea6ee1badf6c1e5f274f925f5f50. Change-Id: Ifb4943b9e9647ae59c1cc6d5fc5076e8620b73ce Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 874c8c56a4883383e49a1e59262113f8eb29486f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMap: add operator+ and - for iteratorsGiuseppe D'Angelo2021-07-273-0/+148
| | | | | | | | | | | | | | We missed the chance of deprecating them in 5.15, so they'll just add to the pain of porting to 6.0. We should not keep them around forever, though; QMap isn't random access and so its iterators should only have bidirectional APIs. Fixes: QTBUG-95334 Change-Id: I3577f7d25e8ab793722d2f220fd27bc85c622b0d Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit cc584c59de644195ae0c4f7f99ad428e189df07d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QHash/QSet: fix squeeze() for default-constructed containerIvan Solovev2021-07-271-1/+5
| | | | | | | | | | | | | | | | | | | | | | QHash::squeeze() was unconditionally calling reserve(0), which is always allocating memory (even for 0 size). This was leading to a confusing situation when calling squeeze() on a default-constructed container with 0 capacity() actually allocated memory. This is very misleading, as squeeze() is supposed to free unneeded memory, not to allocate more. This patch adds a check for non-zero capacity. As a result, nothing is done for default-constructed container. Note that this patch also affects the QSet::squeeze() behavior, because QSet uses QHash as its underlying data type. Task-number: QTBUG-91736 Change-Id: Ib1c3c8b7b3de6ddeefea0e70b1ec71803e8fd3b3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> (cherry picked from commit b095d268788343b67a3995db7148dcc3af9bde1a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QDuplicateTracker: bring back appendTo() &&Marc Mutz2021-07-271-1/+19
| | | | | | | | | | | | | | | This reverts commit c19695ab953c979f15bbc72c4f4a453e9a114cf6. Just because QSet has limited API doesn't mean we can't provide this in an efficient way for std::unordered_set :P Added tests. Change-Id: I4f8f0e60c810acdc666cf34f929845227ed87f3b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 8c49ae522d184deb5a9118ba2368629709ff6e85) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Ensure deprecated APIs in Qt Core are documented as suchNico Vertriest2021-07-232-7/+7
| | | | | | | | | | | Added \deprecated [version_since] when needed Remove references to deprecated functions in \sa statements Fixes: QTBUG-94534 Change-Id: I3b3d4277d63fc5d6d207c28ff2484aed30b83247 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit a2c8184b6b241b063e9af005edf082e653dfd8a6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QSet::erase - extend docsIvan Solovev2021-07-211-0/+5
| | | | | | | | | | | | | | Explicitly specify that calling this method for an empty set or with an invalid iterator results in undefined behavior. On a debug build an assert is triggered in such case, but on a release build it will access the incorect index of an array. Task-number: QTBUG-91736 Change-Id: Ibc3e91512a0ad9d9779a41083fedb8a91780380b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit e5ec09ba868685ab2f943b39732a3cac018fedad) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix quadratic performance hit in Q(Multi)Map::insert() with hintEdward Welbourne2021-07-211-9/+19
| | | | | | | | | | | | | | | | | | | | | | | | The insert() overloads that took a const_iterator started by calling std::distance(begin(), pos) - which has a cost linear in how far pos is from begin() - in order to, after detach()ing, obtain an iterator at the same offset from the new begin(), using std::next() - also linear. This leads to quadratic behavior when large numbers of entries are added with constEnd() as the hint, which happened to be tested by tst_bench_qmap. That wasn't running, due to some assertion failures, but once those were fixed the hinted tests timed out after five minutes, where their unhinted peers completed comfortably within a second. Check whether detach() is even needed and bypass the std::distance() / std::next() linear delay when it isn't. This brings the hinted tests down to running faster than their unhinted equivalents. Task-number: QTBUG-91713 Change-Id: I6b705bf8fc34e67aed2ac4b3312a836e105ca2f2 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 33c916577389fa6607b0b2f6a78da4a0eb485000) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QDuplicateTracker: port reserve() from int to qsizetypeMarc Mutz2021-07-131-1/+1
| | | | | | | | | Was missed in the int -> qsizetype port for Qt 6.0. Change-Id: I1ae8190601f2e1a1bc02a736c12230a9c71acb18 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit fcfc854def12500658d5d863797169279b698498) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QDuplicateTracker: reserve() for at least Prealloc elementsMarc Mutz2021-07-131-2/+3
| | | | | | | | | | | We have space for so many elements, so reserve()ing anything less makes no sense. Change-Id: I84d692b10a6a491c37661f84aa3fdd9af43d71e5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 16db1d21659793909bd1719805d7ff8de6906f88) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QDuplicateTracker: fix the static buffer size calculationMarc Mutz2021-07-131-1/+7
| | | | | | | | | | | | Instead of just sizeof(T), we, of course, also need to take the support structure into account, to wit: the bucket list and, in the node, the next pointer and the stored hash value. Change-Id: I8227a95c49e316aacf3d4efd8f6170ea3bea1cf0 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 3c88e12beb22d8ea11b8a7006a71ba9773c6d183) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMultiMap::erase - extend docs to specify iterator limitationsIvan Solovev2021-07-121-0/+4
| | | | | | | | | Task-number: QTBUG-91736 Change-Id: I7cd58e010af5dd59404e37c55f6ebd91c4631b3f Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit d1d9caf12d103957dccc867c349c4514a28cfe6c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMap::erase - extend docs to specify iterator limitationsIvan Solovev2021-07-091-0/+4
| | | | | | | | Task-number: QTBUG-91736 Change-Id: I4a226e0bbcde91f3149db9a0697981169ec25276 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit 74d6c36eb7b80cfdecd80c5e6f8c1f0604f0b496) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMultiHash::find - prevent detaching shared nullIvan Solovev2021-07-091-1/+3
| | | | | | | | | | | | | | Do not detach when find(key, value) is called on an empty QMultiHash. As a drive-by: fix return value for QMultiHash::remove() in case of empty QMultiHash. Task-number: QTBUG-91736 Change-Id: I1e32f359e7ee9ce8403dae79d02e0b88a20ec4a5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 82499f81478032911d8f788aa28e8d780b31c973) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix QMultiHash::keys(const T&) overloadIvan Solovev2021-07-091-1/+1
| | | | | | | | | | | | | The method was never tested, but it failed to compile after QMultiHash was introduced as a separate class in 6.0. This patch fixes it and adds some unit-tests to cover the case. Task-number: QTBUG-91736 Change-Id: I5dd989d4775efc6a9bb13c5ed1d892e499d95dc2 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit a8bcf68a5ec91b4ca4209c36310def145c8afe97) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QCryptographicHash: don't present the same data over and over againMarc Mutz2021-07-051-3/+1
| | | | | | | | | | | | | | | | | | | Need to decrement 'remaining' (check), but also increment data (meep). Testing is a bit complicated, as most algorithms are just too slow to fit into the 5min QTestLib timeout. Picked the fast ones and Sha512 (which completes here in < 17s, with threads), at least. Amends e12577b56396cca0df05f88f8787706a3a12c82d. [ChangeLog][QtCore][QCryptographicHash] Fixed a bug where presenting more than 4GiB in a single addData() call would calculate the wrong result(). Change-Id: Ic72916ebc33ba087d58225af6d8240e46e41f434 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 35453446a511366e1250858b249e36c80b6ad044) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix rvalue overload of qobject_pointer_cast for GCC 9.3Marc Mutz2021-07-031-5/+1
| | | | | | | | | | | | | | | | The code assumed that any C++ implementation would implement the resolution for LWG2996 in C++20 mode. While that may be the case in the future, the current state in GCC 9.3 as shipped in Ubuntu 20.04 LTS is that it doesn't, which leads to tst_qsharedpointer fail there. Fix by using the safe version of std::move, std::exchange, which guarantees the state of the src object, no matter what the callee does. Change-Id: Icc39b527df4d3a7b398ff2b44bcbdf9082b81f2f Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit 0632494bd47e924ce7914b6457791d4612599e5f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QVarLengthArray: fix aliasing error in insert(it, n, v)Marc Mutz2021-06-281-1/+1
| | | | | | | | | | | | | | | | | | Taking the copy after the resize is completely pointless: the copy is there to ensure that `t`, being a reference potentially aliasing an element in [begin(), end()[ before the resize(), isn't invalidated by the resize(), so it must be taken before resize(). Add a comment so the next rewrite doesn't cause this to be mixed up again. [ChangeLog][QtCore][QVarLengthArray] Fixed an aliasing bug affecting insertions of objects aliasing existing elements. Change-Id: I26bc449fa99bf8d09a19147a12a69ac4314cc61d Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit 6e57e41f9aef5ccfa122c10bc6253d47dafd93d2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Consistent indentation for BINDABLE propertiesAndreas Buhr2021-06-241-2/+2
| | | | | | | | | | Triggered by API review in Gerrit patch 355960. Task-number: QTBUG-94407 Change-Id: I7cafc1cc9d4b929040b53c6bf92c91d73c3b39f2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 4b850065b1631437b65542b3cb1c16077d2f0230) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add missing limits includeNicolas Fella2021-06-201-0/+1
| | | | | | | | | The code uses std::numeric_limits but is lacking the appropriate include Change-Id: I41fa5ac4d8c4e06f35b5b1551ef2ad8417df80bd Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit 2b2b3155d9f6ba1e4f859741468fbc47db09292b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QHash: Fix erase() edge-caseMårten Nordheim2021-06-181-1/+4
| | | | | | | | | | | | | | | | | | | | | | When the element you want to erase is the last element AND the next element (element 0), when rehashed, would be relocated to the last element, this leads to the state below. Which is similar to a test in tst_qhash for some seeds. auto it = hash.begin + (hash.size - 1) it = hash.erase(it) it != hash.end By forcing the iterator to increment if we were erasing the last element we always end up with a pointer which is equal to hash.end Befriend the tst_qhash class so we can set the seed to a known-bad one Change-Id: Ie0b175003a2acb175ef5e3ab5a984e010f65d986 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit ea7d87b5b59ded22b145ecbb4dd648ecfd1abbdd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QList: more explicitly document capacity() shenanigansAndrei Golubev2021-06-171-3/+4
| | | | | | | | | | | | Due to capacity() reporting the size of all allocated space, this is somewhat inconsistent with what QVector::capacity() in Qt5 provided, due to Q6List being double-ended. So let's document this better Task-number: QTBUG-92941 Change-Id: Iba46389121e721a8d21f0344b154f41c2c245867 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 976cf0152b52be5e30abf3b40cd80e072f0cbfd6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: QtCore: Fix documentation issuesTopi Reinio2021-06-011-1/+0
| | | | | | | | | | | | | | | | | | * Add module header wrapper that loads the real QtCore header and qandroidextras_p.h to generate docs for those types * Add missing dummy typedefs to doc/include/jni.h * Use the correct \namespace name (QtAndroidPrivate) and mark it as \preliminary * Add missing 'const' specifier for Q[Untyped]Bindable methods * Drop documentation for removed method QProperty::markDirty() * qmath.h: Fix \fn commands for qFloor(), qCeil() * QHashSeed: Drop incorrect usage of \relates Fixes: QTBUG-93942 Task-number: QTBUG-93995 Change-Id: If76b5aa4b79a64add3cb6275eac82ec44ef10319 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QList: do some minor cleanups in the internal codeAndrei Golubev2021-05-272-2/+1
| | | | | Change-Id: I7e502e4d2fa5af94c20e7da62d1c06597b6b16a7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Doc: Use \deprecated instead of \obsoletePaul Wicking2021-05-267-15/+15
| | | | | | Task-number: QTBUG-93990 Change-Id: I4e512354a49dde6678ca89cabc56bc76ba666bb3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QSharedPointer: Use matching new/deleteFabian Kosmale2021-05-252-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | When a weak pointer calls getAndRef and there is no strong reference yet, getAndRef creates a new ExternalRefCountData. Normally, ExternalRefCountData is never constructed directly, only its subclasses are constructed via placement new into a memory buffer. To that end, ExternalRefCountData has a custom operator delete, which calls the global operator delete (do deallocate the memory buffer correctly). When using operator new directly in getAndRef, gcc notices a new/delete mismatch with the delete in the same function: global operator new matched with class operator delete. This isn't actually an issue in practice, as the class operator delete simply calls the global delete. But to avoid the warning, we can simply call the global operators explicitly. To make it clear that allocation of ExternalRefCountData requires some care, we additionally delete the class operator new, and only allow placement new (or usage of global operator new, as in getAndRef). Pick-to: 6.1 Task-number: QTBUG-93360 Change-Id: I132d1e4e07520eadc5b8f3f955c06aecec80c646 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHash: fix qHash(std::pair)Thiago Macieira2021-05-231-2/+15
| | | | | | | | | | | | | | There were two problems here: first, qHash(std::pair) must be declared before qHashMulti that might call back to qHash(std::pair) (i.e., a pair with one element that is also a pair). But moving the declaration above causes the second problem: the noexcept expression can't refer to qHash functions that aren't declared yet. So we forward-declare a constexpr function for that result, but implement it far below. Fixes: QTBUG-92910 Change-Id: Ia8e48103a54446509e3bfffd16767ed2e29b026c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRandomGenerator: let qt_initial_random_value() return 128 bits of dataThiago Macieira2021-05-231-1/+2
| | | | | | | | | | | | It's how much there is in Linux's AT_RANDOM block. I've also removed the check for validity. It's highly unlikely that 128 bits are bad. Change-Id: Id2983978ad544ff79911fffd16723161ea7ec315 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QHash & QRandomGenerator: cooperate to provide a simpler initial seedThiago Macieira2021-05-231-4/+10
| | | | | | | | | | | | | | | | | | | | | | Instead of initializing the whole QRandomGenerator::system(), which in turn gets to checking CPUID and whether the HWRNG works, trust the operating system functions for an initial value. On Linux, we'll use 4 or 8 of the 16 bytes of random data that the kernel populates for us on AT_RANDOM. This should make Qt applications not stall on an early system launch without an RNG daemon, if compiled without getentropy() support. And avoids silly mistakes causing recursion, like QTBUG-78007 found. Additionally, qt_random_initial_value() will most likely not throw either. It's marked noexcept, even though SystemGenerator::fillBuffer could throw on Linux, if the current thread is canceled, but Linux also has AT_RANDOM. That leaves the other Unix systems without getentropy() (read: macOS, since the BSDs have getentropy()). Fixes: QTBUG-69555 Change-Id: Id2983978ad544ff79911fffd1671fca1a9f9044d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Deprecate qGlobalQHashSeed and qSetGlobalQHashSeed in Qt 6.6Thiago Macieira2021-05-233-3/+9
| | | | | | | That's two years from when the replacements were added (6.2). Change-Id: Id2983978ad544ff79911fffd1671f7dd38fede02 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Mark QHashSeed::globalSeed() noexceptThiago Macieira2021-05-232-6/+9
| | | | | | | | | | | | | | | It is noexcept, except when initializing. When initializing, let's just use qEnvironmentVariableIntValue (which we should have used anyway), which avoids the memory allocation and is noexcept. The QRandomGenerator functions are not marked noexcept, but are mostly so: they can't throw regular exceptions, but some implementations do call POSIX Thread Cancellation Points, which may cause forced stack unwinding. That's unlikely to happen at the moment of the QHash initialization. This is also mitigated in the next commit. Change-Id: Id2983978ad544ff79911fffd1671fd16f8d6378d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Introduce QHashSeed and switch to size_t seedsThiago Macieira2021-05-233-36/+140
| | | | | | | | | | | Commit 37e0953613ef9a3db137bc8d3076441d9ae317d9 added a to-do, but we can actually change the type, since we've documented since Qt 5.10 that setting a non-zero value (aside from -1) with qSetGlobalQHashSeed was not allowed. Storing a value to be reset later is simply not supported. Change-Id: Id2983978ad544ff79911fffd1671f7b5de284bab Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Use __has_* instead QT_HAS_*JiDe Zhang2021-05-212-2/+2
| | | | | | | | Use __has_include instead QT_HAS_INCLUDE Use __has_feature instead QT_HAS_FEATURE Change-Id: If9b0af1f4386f7bcae6ca2fb911ffaba422750dd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add runtime ARM64 AES checkAllan Sandfeld Jensen2021-05-201-3/+8
| | | | | | | | | | | | Adds runtime CPU detection for Windows and macOS, and switches feature detection of AES to runtime like for x86, So far only on ARM64, since gcc doesn't do function versioning on ARM32, but clang can, so it could be added later. Change-Id: Ibe5d60f48cdae3e366a8ecd6263534ba2b09b131 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QArrayData: store the right flag type, not an intGiuseppe D'Angelo2021-05-173-3/+3
| | | | | | | | There's no reason to be storing `int` in the array data header and then using it as a QFlags. Just store the QFlags. Change-Id: I78f489550d74d15a560dacf338110d80a7ddfdd2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFlags: add qHash overloadGiuseppe D'Angelo2021-05-111-0/+4
| | | | | | | | | Stop going through the implicit int conversion. [ChangeLog][QtCore][QFlags] QFlags now has a qHash() overload. Change-Id: Id380ed252695f24af2e8c239b650dcb6f44e2893 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QScopedPointer: remove doc mention of take()Giuseppe D'Angelo2021-05-061-3/+0
| | | | | | | | It is deprecated so it shouldn't get mentioned by the ordinary docs. Pick-to: 6.1 Change-Id: Ic867fd45396871245d6f5714f6a886c706e99c04 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QHash: disable the AES based one on the bootstrap libraryThiago Macieira2021-05-011-2/+2
| | | | | | | | | | | | | | The bootstrap library doesn't need it. All bootstrapped tools are expected to produce deterministic output, given the enforced seed of 0: #ifdef QT_BOOTSTRAPPED // the seed is always 0 in bootstrapped mode (no seed generation code), // so help the compiler do dead code elimination seed = 0; #endif Change-Id: I755911ae7d0341f49039fffd167afc934ff1c9e1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix comparison between nullptr and QWeakPointerVille Voutilainen2021-04-281-3/+9
| | | | | | | | | | | | | | | | | The comparison between nullptr and QWeakPointer was just bogus and ill-formed. The INTEGRITY compiler catches that even if nothing tries to use the comparison. It is an ill-formed, no diagnostic required case of a function template never being able to produce a valid specialization. And while we're at it, this patch makes the result of comparing a nullptr to a QWeakPointer or vice versa the same as asking .isNull() from the weak pointer, because it seems mind-boggling if those are not the same operation. Task-number: QTBUG-93093 Change-Id: I0cc80e795c9af2be1b76de05157aa458ef260f2e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change QList's insert() and emplace() to always invalidate [pos, end())Andrei Golubev2021-04-271-107/+114
| | | | | | | | | | | | | | | | | Drop the "move left if pos <= size / 2" path in favor of reference stability of insert and emplace operations Leave the insert(0, ...) and emplace(0, ...) as special cases for prepend optimization as invalidating [begin, end()) practically means that we can reallocate behind the scenes Doing this also simplifies the code a bit Task-number: QTBUG-93019 Change-Id: I7c248f96d687e94a6a38f81ade901619ff2b4733 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 5e76c2acff2c70f2893306b16aeba230f3d6114a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Do not shift the data pointer when removing all elements from QListAndrei Golubev2021-04-271-5/+7
| | | | | | | | | | | Because leaving the pointer untouched is a much more expected behavior The tests for this (and not only) logic can be found in the following commit Change-Id: Iec9eec9bbce04c9fd90cb6be9627c135cd989b7f Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 38bba2a87c6c5c2b8100870add6d0d7ad559e669) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Resurrect data moves in QListAndrei Golubev2021-04-274-42/+280
| | | | | | | | | | | | | | | | | Use the data moves to readjust the free space in the QList, which ultimately fixes the out-of-memory issues caused by cases like: forever { list.prepend(list.back()); list.removeLast(); } Task-number: QTBUG-91801 Task-number: QTBUG-91360 Task-number: QTBUG-93019 Change-Id: Iacff69cbf36b8b5b176bb2663df635ec972c875c Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit a0253f5f0249024580050e4ec22d50cb139ef8d9)
* Add q_points_into_range to container utilitiesAndrei Golubev2021-04-271-0/+13
| | | | | | | | | | We already used it in QString and QBA. And implicitly in QADP (see parent commit). Might as well move to a common location and reuse Change-Id: I694f0f1dbd109f17c134f64b3f3dc28d19556c88 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 10b46e7f0faecc42a94cc2e25ad3edd08ae28083) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Port of QTimeLine to new property systemAndreas Buhr2021-04-262-49/+111
| | | | | | | | | | | | | The six properties duration, updateInterval, currentTime, direction, loopCount and easingCurve have been ported to the new property system and are now bindable. Drive-by renamed a local variable to avoid shadowing. Task-number: QTBUG-85520 Change-Id: Ibabf106f5200d2dd4329a1e1f96112eccc29d6b1 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDuplicateTracker: store the current seed in the hasherThiago Macieira2021-04-221-1/+2
| | | | | | | | It's allowed to change asynchronously by another thread. Pick-to: 6.1 6.0 5.15 Change-Id: I6cdea00671e8479b9c50fffd167836a08a42cc1d Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Add runtime aes/crypto check for ARMAllan Sandfeld Jensen2021-04-211-1/+3
| | | | | | | Yocto apparantly enables it hard at compile time. Change-Id: I1d4c7402eacc714859c61f469ebed85682d48b51 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* MSVC: Fix size_to to int warning in qhash.cppKai Köhne2021-04-211-1/+1
| | | | | | | Pick-to: 6.1 Change-Id: I5da2ae57b0f626bd46b71bab28af668bd1fbc7de Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHash: allow an empty QT_HASH_SEED env variable to resetThiago Macieira2021-04-161-1/+1
| | | | | | | | | | | | | | | | | | It's much easier to un-do a QT_HASH_SEED=0 by simply setting it to empty in a command-line, as in: QT_HASH_SEED= ./appname [ChangeLog][Important Behavior Changes] Previously, if the QT_HASH_SEED environment variable was set but empty, Qt would interpret that as if it had been set to 0, thus disabling the hash salting functionality. Since this makes setting and unsetting this variable difficult in scripts, it has been changed: if the variable is set but empty, it is interpreted now as if it had not been set and the hash salting functionality is enabled. Change-Id: Id2983978ad544ff79911fffd1671f5473978a6bc Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>