summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
* QArrayData: fix exception safety in assign()Marc Mutz3 days1-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As mentioned at the top of assign(), the function ought to provide the basic exception guarantee. We were checking whether the construction of T from the result of the projection is noexcept, but, as Thiago pointed out in a related change, we ignored that the projection invocation can fail, too, in which case we'd leave a corrupt container around (size would not match the number of active objects in the list, holes in the middle if we started to use the prepend buffer, but failed in the middle). To fix, also check the projection for noexcept and fall back to the existing non-noexcept-construction paths in that case. It's pretty harmless, since the functionality isn't exposed in public API (if you consider QArrayData* non-public, that is), and the only user of projections was QString::assign(), and the projection it uses cannot throw (cf. f2ea9d8dc8dc8d52490722f78ea46cd374d8e649). Amends 782ccc6de5950ff1f6d3eeaaeacc7af4bc97a84f for the first hunk and e07710007b4cf9c0665ac9d5c2b6c7ef588aae0a for the second. Because of a massive code-move and -rewrite that has happened in dev, I decided that it's simpler to fix this in 6.10 and forward-port to dev, as it's one less conflict to resolve. Manual conflict resolution for dev: - dropped the original's second hunk, as that code is gone in dev Fixes: QTBUG-141899 Change-Id: I026f703e5245422dce2951fd733178b5a0a4eefe Reviewed-by: Dennis Oberst <dennis.oberst@qt.io> (cherry picked from commit 73fa4cf2004690ae71ed9c41a93aa071fda98ecc) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QHashDummyValue more robustMarc Mutz3 days1-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | As is customary for tag structs, make the default ctor explicit to avoid construction as '{}'. Make op== constexpr (drive-by: make it a hidden friend instead of a member function), and add op!= to C++17 builds, for symmetry. =delete the qHash() overload so it doesn't accidentally match some other overload. We should eventually also =delete equality, but atm, this breaks QSet::compareEquals, which calls QHash::op==, which (incorrectly) SFINAE's out for a non-equality-comparable QHashDummyValue mapped_type. Amends 5b7c3e31b538376f2b4733bd868b5875b504cdb3. Not picking back, as it's a rather isolated change with very little chance of creating conflicts going forward, but non-negligible chance of breaking something in older branches. Change-Id: I8125581c476f854ebe4f9ddc791d3ddce9f169d0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHash: fix noexcept on Node::takeValue()Marc Mutz4 days1-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | In the QHashDummyValue specialization, the noexcept was missing. Add it. In the primary Node template, takeValue() was conditionally noexcept, but seeing as it just returns an rvalue reference to the 'value' data member, it's of course unconditionally noexcept, since the actual move contructor or -assignment operator call happens after the function returns. Besides, even if it had to be conditionally noexcept (e.g., because it returned T-by-value), it would have to check for nothrow_move_constructible, not _assignable. Amends 5b7c3e31b538376f2b4733bd868b5875b504cdb3. Picking to older branches is ok, since these functions, even if they were marked noexcept(false), could not throw any exceptions, so forward BC is not broken. Pick-to: 6.10 6.8 6.5 Change-Id: I43aab284acc8b1303d4147c1b8c58613bbb05b25 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Turn QHashPrivate::isRelocatable into a variable templateMarc Mutz4 days1-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | (was: function template) Coverity complained that, when instantiating a QHash with is_same<mapped_type, key_type>, the two terms of the logical AND operator were identical. This is, of course, expected and perfectly as intended, but in the interest of fixing-instead-of-dismissing, try whether making the entity a variable template intead of a function template will fix the Coverity complaint, too. After all, this is how you would write the entity today, in C++17. As a variable template, add the idiomatic _v suffix (to explicitly break out-of-tree users, if any, with a clear error message). Amends 5b7c3e31b538376f2b4733bd868b5875b504cdb3. Coverity-Id: 378449 Change-Id: I1dab5d18d6f55edd58e16b9773403cee2f93dfee Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QArrayDataOps: allow truncate(samesize)Thiago Macieira5 days1-2/+2
| | | | | | | | | | | | | | | | | | There's no reason to disallow truncating nothing. The alternative is to check the size before truncating, which is unnecessary extra branching. Instead, just let this function do nothing. Amends 15e3ae6b9da9b32236d3e3348ede86c3acf06fb4 ("Introduce QArrayDataOps::truncate") from Qt 5.0 but cherry-picking nowhere near as far back because nothing used it until assign() in Qt 6.8. QList does not have a truncate() function and both QString's and QByteArray's use resize() instead. Pick-to: 6.10 6.8 Fixes: QTBUG-141918 Change-Id: Ie3342e0ea9ee312bd5cbfffd4d4a83da27a838e6 Reviewed-by: Sune Vuorela <sune@vuorela.dk> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QMultiHash: remove an unneeded std::move()Marc Mutz6 days1-1/+1
| | | | | | | | | | | | | | | | | | The old code use std::move() on the result of Node::takeValue(). Node::takeValue() currently returns a T&&, which already is an rvalue. Even if the return value gets changed to T-by-value at some point, it still will be an rvalue, so we can safely drop the std::move here, as the argument is already an rvalue. Amends d281f5cc35a974840441e8ed2587bbe74789e9ee. Safe to pick, since takeValue()'s signature hasn't changed since before Qt 6.0 (5b7c3e31b538376f2b4733bd868b5875b504cdb3, specifically). Pick-to: 6.10 6.8 6.5 Change-Id: I2be3241d735e3e2931ab2cc8f13720e0b4629181 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Support assignment from empty bracesPavel Dubsky10 days1-1/+5
| | | | | | | | This makes resetting a handle more natural and idiomatic, matching modern C++ expectations without affecting existing semantics. Change-Id: I85e3c2e8b0d4c288d90b1739b83994d345a757ed Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Add internal documentation for QtPrivate::CompactStoragePavel Dubsky11 days1-0/+58
| | | | | Change-Id: I6ba6c7090350282c87e618ff603586217adf4221 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QArrayDataOps::assign: improve for forward iterators (redux)Thiago Macieira11 days1-27/+63
| | | | | | | | | | | | | | | | | | | | | | | | | This differs from commit 37b37cddb67febd595cb06b54ac08f1e676ead4d in that it takes the prepend optimization into account in the new implementation, instead of leaving it up to the assign() caller. For the simple case of trivial types and identity projection, the fix was simple: just start copying from the beginning of the prepend optimization. For the non-identity projection or non-trivial types, there are now four possible regions (at most three of which can appear in any given condition) instead of three. And because there are two exit conditions for the prepend optimization and regular array, we must use iterators instead of a simple counter. This code is as exception-safe as the original: it isn't. If the copy constructors or copy assignment operators throw, the size of the container will not have been updated, so we'll either leak objects or access garbage ones when the container is destroyed. I don't care. Fixes: QTBUG-141366 Change-Id: Ibd7b16127e8a815b6725802029d082f1e39782b4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QArrayDataOps::assign: fix race condition in getting capacityThiago Macieira11 days1-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amends commit ae688468590dedc82cca900332a625c82e87471b. We need to get the currently-stored capacity (if any) before deref()'ing the d pointer, because after that another thread could deallocate it. Ideally, having already checked the allocated capacity a few lines above, the compiler already has the value somewhere and only needs to check the CapacityReserved flag. Which Clang 21 does: movq 8(%rax), %rbp # load d->alloc cmpq %rbp, %r13 # compare to the input range's size jle .LBB1_3 cmpq %rbp, %r13 # compare again cmovgq %r13, %rbp, %r12 # conditionally move the greater testb $1, 4(%rax) # check d->flags & CapacityReserved cmoveq %r13, %r12 # conditionally move if unset lock decl (%rax) But GCC 15 doesn't (yet): movq 8(%rax), %rdx # load d->alloc movl $1, %esi #, needCapacity cmpq %rdx, %r13 # compare to the input range's size jle .L18 #, testb $1, 4(%rax) # check d->flags & CapacityReserved je .L8 #, movq 8(%rax), %rcx # load d->alloc again cmpq %rcx, %r13 # compare to the input range's size (again) jge .L8 #, .L7: lock decl (%rax) #,* _12 Change-Id: I8cc7cb05d04fba763d41fffdf762c846c76d78a9 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QuasiVirtual: remove unnecessary limitation for static assert checkArtem Dyomin11 days1-6/+6
| | | | | | | Instead of mask, constexpr std::array<bool> can be used. Change-Id: I912b00e2ac82d67536fd6ce516d6c4a9d4d1b6c1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Move QQuasiVirtual to a separate headerArtem Dyomin11 days1-0/+241
| | | | | | | No functional changes. Change-Id: Iacbae1e04d9a9edd35acce17fd7ecf268fbe9340 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Fix or remove self-referencing "see also" linksDavid Boddie13 days1-1/+1
| | | | | | | | | | Use a precise signature for a QMultiMap::count() overload. Remove links to QRandomGenerator64 functions as defines in the header file hide them from QDoc. Task-number: QTBUG-137048 Change-Id: I75994ae96d385d08730e3afc849fe81ea9e88dee Reviewed-by: Topi Reinio <topi.reinio@qt.io>
* Add support for stateful deleters in QUniqueHandlePavel Dubsky2025-11-061-10/+93
| | | | | | | | | | | | | | | This change updates QUniqueHandle to follow the std::unique_ptr model, introducing a Deleter type that can be stateful. The deleter is stored using CompactStorage, allowing stateless deleters to incur no additional cost through empty base optimization. This enables handle traits to define custom deleters that carry any required context when releasing resources (for example, ReleaseDC needing both an HDC and an HWND). Change-Id: I961744569b776ad7e22780bfe81a04d6051a6194 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Add styled SVG versions of PNG diagramsDavid Boddie2025-11-051-10/+10
| | | | | Change-Id: I6ef2f7f8f88f6019cfba98d7d45c5cc1b7d0cc82 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QBasicAtomicInteger: Add (internal) refRelaxedFabian Kosmale2025-10-271-1/+1
| | | | | | | | | | | | | | | | | | | | It is known that incrementing the refcount can use relaxed semantics, compare https://web.archive.org/web/20251016043603/https://devblogs.microsoft.com/oldnewthing/20251015-00/?p=111686 However, we can't modify QBasicAtomic::ref, because that is documented to use "ordered" semantics. So introduce a new (internal) refRelaxed method, which simply calls fetchAndAddRelaxed(1) instead. Compared to ref, we also do not return anything, as no expected user has a need for the return value (and it only causes more work for the compiler to get rid of it again). Our deref operation is still using acquire_release semantics, so everything is fine. Port QArrayData to use it as a first user so that the functionality is tested. Change-Id: I678870551fe85b83d9bb073ddb5947e649845264 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QList::assign: optimize for empty std::initializer_listThiago Macieira2025-10-231-1/+6
| | | | | | | | | | | | | Happens often when one writes: l = {}; For the vast majority of cases, the size is a constant because the std::initializer_list is an automatic variable, so this should not result in extra conditionals in the code (in release mode, of course). Pick-to: 6.10 6.8 6.5 Change-Id: If90fc920810f42ab68e5fffdc7a254b2e3f709a7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QList: call the two-arg qHash() functionThiago Macieira2025-10-231-2/+2
| | | | | | | | | | The single-arg one is deprecated. Let's stop using them in tests. Drive-by test that hashes work for zero and non-zero seeds. Pick-to: 6.10 6.8 6.5 Change-Id: I5b32acf0797e9e62a5b7fffd1bc44f5372a044cf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Revert "QArrayDataOps::assign: improve for forward iterators (typical case)"Fabian Kosmale2025-10-211-45/+18
| | | | | | | | | This reverts commit 37b37cddb67febd595cb06b54ac08f1e676ead4d. Reason for revert: This caused QTBUG-141366 Change-Id: I1f878386e969f986bbd9c289b0b9a1fe8e9daaf7 Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* Q{Explicitly,}SharedDataPointer: share most codeThiago Macieira2025-10-201-129/+194
| | | | | | | | | | | | | The majority of the code for the two classes is identical, so we can share code. QExplicitlySharedDataPointerV2's is different... and wrong? We need explicit constructors, assignment operators, and destructors to prevent early instantiation of the base class's equivalents, which break compilation of classes using the QT_DECLARE_Q(E)SDP_SPECIALIZATION_DTOR macros. Change-Id: I9e3cde075b537c61e8fcfffdb7a1a2d74b399967 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Long live Q_PRESUMETim Blechmann2025-10-201-3/+1
| | | | | | | | | | | | | | | | | Q_PRESUME wraps a Q_ASSERT/[[assume]] and can be used as a stop-gap until [[assume]] can be used unconditionally. It has stricter semantics than the deprecated Q_ASSUME and is helpful to silence static analyzer warnings. Documentation and [ChangeLog] in the next commit so it won't be cherry-picked. Fixes: QTBUG-141074 Pick-to: 6.10 Change-Id: Id5376bcc5e9e9708c836ceff5eea982c2b0e382e Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Tim Blechmann <tim.blechmann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QCryptographicHash: hashInto(): write directly into the given bufferAhmad Samir2025-10-201-13/+25
| | | | | | | Pick-to: 6.10 Fixes: QTBUG-125521 Change-Id: I1cdf2fe38799f36e04903ae5f8a5b4e2050bad50 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QArrayDataOps::assign: improve for forward iterators (typical case)Thiago Macieira2025-10-181-18/+45
| | | | | | | | | | | | | Similar to commit 7ed2db674328f1c96d06be5ffb15b8ffefeae545, which did this for QVarLengthArray. This disentangles the forward iterator case from the more complex, iterative input-only iterator one, because we know the final size from the beginning. This generates far better code for the more common uses of random-access iterators and especially that of trivial types. Change-Id: Ib71e489ae0dafb7a917bfffd3441d8c14b82ad46 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QArrayDataOps::assign: simplify undoing the prepend optim. for trivialsThiago Macieira2025-10-181-1/+6
| | | | | | | | | | | | | | | Since they are trivial, we don't need to loop destroying anything (dead code anyway), so help the compiler out and always store the new capacity begin. This may be storing the value that was already there if no element was removed from the beginning of the list, but it does remove a conditional. Further, this removes the entire looping over the prepend optimization buffer for new elements. We'll fall straight to the main assignment loop. Change-Id: I5338b6a53bffbda17a08fffd1d7eda72d57eff29 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QArrayDataOps::assign: invert how we find the beginning of the capacityThiago Macieira2025-10-181-12/+14
| | | | | | | | | | | | | | | Ideally the equation would be the same: offset = this->ptr - Data::dataStart(d, alignment); capacityBegin = this->ptr - offset; => capacityBegin = Data::dataStart(d, alignment) But codegen isn't as simple as that, so invert and use QADP::dataStart() to calculate the beginning of the allocated capacity and only if needed calculate how many elements we must destroy/overwrite. Change-Id: Ib716ed04c4684964ec0dfffd473c635456062bde Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QArrayDataOps::assign: reuse capacity if this is the last referenceThiago Macieira2025-10-181-3/+17
| | | | | | | | | It's a waste to allocate new memory, then deref the old and free it, if we can still use it. This detach-me-for-growth code may be useful in other places too. Change-Id: Ie4d7300589ff21b0aa03fffdb7a74c01c385d842 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QArrayDataOps::assign: make the detaching case common to all iterator typesThiago Macieira2025-10-181-9/+7
| | | | | | | | This only simplifies the code and enforces offset = size = 0 if we've just detached. Change-Id: Ia5d667fc0f528eaa154bfffde155e28f54f7a8ff Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QArrayDataOps: move assign() from QArrayDataPointerThiago Macieira2025-10-183-99/+97
| | | | | | | | The implementation was already using the Ops (like in (*this)->emplace), so this is only natural. We want to access the extra operations anyway. Change-Id: Id1f422be54154f2c41b0fffd416dcb1916e8f022 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Doc: Remove duplicate function declarationDavid Boddie2025-10-091-1/+1
| | | | | | | | This removes a duplicate, identically-named entry for peekNext() in QMutableMapIterator. Change-Id: I83bd3290bed2dca2a4d32e231a9437162d4947b5 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* (QRect) Diagram not readable in black mode fixEren Bursali2025-10-091-4/+4
| | | | | | | | | | | Fixing image "qrect-unite.png" being unreadable in black mode in "https://doc.qt.io/qt-6/qrect.html#details" by adding a white background to the image Fixes: QTBUG-140872 Pick-to: 6.10 Change-Id: I629a5a454a59f2a70abcdf77d7d404f6ff4efe39 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* (QtCore) doc: Add alt text for \image tagsEren Bursali2025-10-093-52/+126
| | | | | | | | | Adding alt texts that were needed for QDoc QTBUG-135118 Change-Id: Ie1b1cee06342803907b2c3d3bfd88191e3f175d8 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Doc: Fix broken "see also" linksDavid Boddie2025-09-263-5/+5
| | | | | | | Pick-to: 6.9 6.10 Change-Id: I9a7386691d4a852bb687310d6c7a91b78328fe8c Task-number: QTBUG-137048 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Modernize QHash iterator documentationPaul Wicking2025-09-091-9/+14
| | | | | | | | | | | | | | | | | | | | | | Promote STL-style iterators as the primary way to iterate over QHash. Replace the detailed explanation with direct guidance to use QHash::asKeyValueRange, and move Java-style iterators to a brief compatibility note. Update snippets to: - Show C++17 structured bindings with std::as_const(hash).asKeyValueRange() (add <utility> header std::as_const). - Add STL-style iterator example for manual control. - Add example for modifying values in place. This makes the docs clearer, const-correct, and aligned with modern C++ usage. Fixes: QTBUG-139662 Pick-to: 6.10.0 6.10 6.9 6.8 Change-Id: Ifb9698b93ca53c3c6a7c82b0f1d393105cd62f35 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Doc: QtCore: Add missing \headerfile topicsTopi Reinio2025-09-091-3/+9
| | | | | | | | | | | | | | | | | | | | | A lot of functions and macros previously available under the QtGlobal header have been separated into different, specialized headers. The documentation for these were updated to refer to the new header file names using the \relates command, but a \headerfile topic was missing for a lot of them. As a consequence, QDoc automatically generated a 'proxy' page for these, which look confusing as they lack any description of what the page is. Add \headerfile topics for them, along with \brief descriptions. Fix \relates arguments for type alias QPair and the deprecated function qMakePair() to point to the correct header file. Pick-to: 6.10.0 6.10 6.9 6.8 Task-number: QTBUG-117447 Change-Id: I98114ddb71f78982e390e28e9521e264f3ecf5d0 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* qNextPowerOfTwo: rewrite using the newly added q20::bit_ceil()Thiago Macieira2025-09-091-1/+1
| | | | | Change-Id: I6f6d8110327d1ba7d519fffd0aa2e18d87477e56 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Micro-optimize to ensure named return value optimizationAllan Sandfeld Jensen2025-09-061-3/+5
| | | | | | | | Rewrite a few often used header functions to ensure they get return value optimization. Change-Id: I316fde21f63fedfd9cbae50855007234b0de9b70 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTaggedPointer: fix integer narrowing warning with clang-clTim Blechmann2025-09-041-1/+1
| | | | | | | | | | | | qCountTrailingZeroBits returns uint, which cannot be converted to quint8 without narrowing. clang-cl seems to be pickier than other compilers, as it seems to warn based on the type, not evaluated constexpr. Amends 7eff6ace6143e5bb44fa28c2fb98969bd5483c57 Change-Id: I405f6b513a62559b0cd686bbef7ea8107b9e70f2 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QtAlgorithms: rewrite the functions using q20bit.hThiago Macieira2025-08-282-357/+28
| | | | | | | Which is constexpr on all platforms. Change-Id: I0680e712c96bc3131515fffd2fa97f2f76e0b253 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QLine: de-pessimize dx()/dy()Marc Mutz2025-08-282-2/+4
| | | | | | | | | | | | | | | | | | | | | Because of the use of checked integers in the implementation of QPoint, (pt1-pt2).x() will calculate the y value, too (using checked arithmetic, so we can't expect the optimizer to remove this as dead code). Ditto .y() and x value. This is unnecessary and introduces a failure state where there wasn't one before (e.g. if, while calling x(), pt1.xp - pt2.xp doesn't overflow, but pt1.yp - pt2.yp does). Fix by calculating the difference only for the dimension at hand, which, to keep using checked ints, requires QLine to have access to QPoint::{xp,yp}, so add friendship. Amends 1145e1709d1072f7dd45683e9c25a14615603854. Found in API-review. Pick-to: 6.10 Change-Id: I163beb65da5fc50e5c12e7a140bcfbc1d07a69a6 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QArrayData: Add MSVC attributes to MALLOCLIKEMårten Nordheim2025-08-211-0/+2
| | | | | | | | | | | | | | | __declspec(allocator) marks a function as something that allocates memory, like malloc and new. This doesn't change optimizations in any way, it is just for event tracking and the debugger. __declspec(restrict) is used to indicate that any memory pointed to by a pointer returned by the function is not aliased by any other pointer. This is useful for the compiler to optimize memory access, namely it can reorder stores and loads without having to take into account that the memory might be accessed through another pointer. Change-Id: Ic1320f3a4c17a12c9ac2c45eeb9ed70822380e6e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QArrayData: remove AllocationResult and go back to output parameterThiago Macieira2025-08-051-22/+9
| | | | | | | | | | | The public API must have a single pointer return value because of limitations of GCC's __attribute__((malloc)), meaning we have no option but to have an output parameter for that too. Therefore, this simplifies the internals. Pick-to: 6.10 Change-Id: I0c12029a2f29fbbfd610fffd8d4931eca962b2e3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Docs: Fix documentation for qHash(QByteArrayView)Volker Hilsheimer2025-08-051-1/+1
| | | | | | | | The view is taken by value, not by const ref. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I61ba4ebea80ed70f3cf172a70e77753d1a1126fd Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Remove documentation of non-existing QWeakPointer membersOleksii Zbykovskyi2025-07-302-58/+0
| | | | | | | | | | | | | | For historical reasons, qdoc sees a different declaration of QWeakPointer than the compiler, and when we removed deprecated members from the latter in e40320c552a9ccd4c1879a4da13c8d909b2cd21e for Qt 6.0, we evidently forgot the former. Remove those now from the declaration that qdoc sees as well, so that we don't claim that they exist as deprecated members. Pick-to: 6.5 6.8 6.9 6.10 Change-Id: I1167a9317df727054c0b0bc447083d64b59087bc Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix of files under tools prefixOleksii Zbykovskyi2025-07-293-9/+6
| | | | | | | | Made each file compilable and added them to the build system. Task-number: QTBUG-137566 Change-Id: I51aac946a1bfd8922c6a3669483d4e6f591795b5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Allow disabling the single-argument qHash compatibility overloadGiuseppe D'Angelo2025-07-272-2/+16
| | | | | | | | | | | | | Support for qHash overloads that do NOT take the seed will be removed in Qt 7. Add a macro that disables such overloads immediately, in order to catch such usages and future-proof one's code. Make the macro also be enabled by QT_ENABLE_STRICT_MODE_UP_TO. [ChangeLog][QtCore][QHash] Added the QT_NO_SINGLE_ARGUMENT_QHASH_OVERLOAD macro. Change-Id: Id6eddc72667611219816159289ddfb1ec0928855 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStack: add a rvalue overload for push()Aurélien Brooke2025-07-202-0/+12
| | | | | Change-Id: Ib6dc1d941806910505a6783652e9b02457485bbb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDuplicateTracker: make iterableMarc Mutz2025-07-141-0/+6
| | | | | | | | | | | Avoids the need to do appendTo() just to iterate over all the elements. To be used in tst_QTemporaryFile in a subsequent commit. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I8bcfcb326dd6e5c26b91327b155ee0971776be05 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Revert renaming of QArrayData::ref_Thiago Macieira2025-07-102-7/+7
| | | | | | | | | | | | | | | | This reverts part of commit 3f61f736266ece40d627dcf6214618a22a009fd1. The renaming of the member caused Qt Creator to break. Since that was a gratuitous change and was backported, it's hard to fix. src/libs/utils/stringtable.cpp:97:44: error: ‘QArrayDataPointer<char16_t>::Data’ {aka ‘struct QTypedArrayData<char16_t>’} has no member named ‘ref_’; did you mean ‘ref’? Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I5d0b1a0c9b42adc38c7bfffd1a86e7abb08d952b Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* QWeakPointer: don't let IfCompatible<X> make accidental SMFsMarc Mutz2025-07-091-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The IfCompatible constraint did not exclude the case where is_same<X, T>, so it made accidental copy and move SMFs. This is a problem because the normal SMFs all work fine with a forward-declared T, but conversion construction and assignment inspects X, e.g. by going through QSharedPointer<X> or checking std::is_virtual_base_of, which require types to be complete. Hot-fix by excluding T from IfCompatible<X>. All functions that use this constraint are already also available as overloads for T, except the QObject private ctor, for which this patch therefore adds a new overload. Fixes the FTBFS described in QTBUG-138246, but not the bug itself, which is also about QSharedPointer and qxp::is_virtual_base_of. Amends 014d7ac65417ed9b5ffb85cca24d16564ff5005a. [ChangeLog][QtCore][QWeakPointer] Fixed a regression whereby the QWeakPointer<T> copy or move constructors and/or assignment operators may fail to compile for forward-declared (incomplete) T. Task-number: QTBUG-138246 Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I0b098732cd7dbb373ff2b2dee8deaac3859127a5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* QHashCombine: add a way to make combining results with seed in Qt 6.xThiago Macieira2025-07-041-7/+25
| | | | | | | | | | | Complements commit c05ae82efb33507959ae2082483fb9425ccca8a0, which added the support for Qt 7, but neglected to provide a solution for the cases where the qHash() function of a type was never inline and therefore can be updated to properly hash using the seed. Pick-to: 6.10 Change-Id: I5fb0ed9a2c92440ec0f8fffd0f38568f28cc4363 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>