summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
* QEasingCurve: fix TCBPoint default constructorMarc Mutz4 hours1-3/+1
| | | | | | | | | | | | | | | | | | | | | | | As pointed out by ClangSA highlighing in QtCreator, but also by Coverity, the way the TCBPoint default constructor was written meant that _t, _c, and _b were left uninitialized even if the user value-initialized a TCBPoint object: TCBPoint p = {}; // ought to zero-initialize, but doesn't Fix by removing all the constructors. Being just a POD^Waggregate is more than sufficient for this type and aggregate initialization behaves predictably: TCBPoint p; // partially-formed (_t, _b, _c are uninitialized) TCBPoint p = {}; // well-formed, value-initialized: _t, _c, _b are 0.0 Amends b9f0bde16e85161666d5090952955bebacc40f89. Coverity-Id: 11609 Pick-to: 6.11 6.10 6.8 6.5 Change-Id: I301e5a7b68e86ddf967348b683f7a97fdc0b598d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QArrayData: catch negative capacities earlierThiago Macieira2 days1-1/+1
| | | | | | | | | | | | | | This isn't necessary because we would catch it inside of calculateBlockSize() → qCalculateBlockSize(), because the negative elementCount becomes a large positive one after the conversion to size_t. But since this change is effectively free anyway, we can do it and avoid a future in which those functions don't convert to an unsigned type. Pick-to: 6.11 6.10 Change-Id: I14a1f4f0828ea17ae7bafffdbf2ccddebf54bb2e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QSizeF: clean up after port to QtPrivate::fuzzyCompare()Marc Mutz3 days1-4/+0
| | | | | | | | | | Amends edbe05d1e586e1860b2b5b68888c414300b008d9, which left the (now superfluous) -Wfloat-equal warning suppressions in, as well as a partial comment. Pick-to: 6.11 6.10 6.8 6.5 Change-Id: Ia45bcc8ab1367ed9bf0f6ff9d830eb258ca38dd0 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Short live QtPrivate::fuzzyCompare()!Marc Mutz6 days3-19/+8
| | | | | | | | | | | | | | | | | | | | | Extract Method QtPrivate::fuzzyCompare() from the qFuzzyCompare() implementations that correctly validate the preconditions of the public qFuzzyCompare() (QMarginsF, QSizeF, QPointF), so we can more easily apply the same technique to other in-tree callers. In the process, replace comparison to literal 0.0 with calls to qIsNull() so we're a) insulated from -Wfloat-compare and b) have a customization point to extend to types other than float and double. Amends: - 473d06970d224b202e7a8ee8feaa2a2d98d5b257 (QMarginsF) - fa0d77e290f5ccb5afa7d02716f8726aa6b810e6 (QPointF) - 3ca9877f8cae41e1b1cb3c72d4a7872d97fb8254 (QSizeF) Pick-to: 6.10 6.8 6.5 Task-number: QTBUG-142020 Change-Id: Ib7ec06822f8006771a1c3a96145e98d574a29fbe Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QFlatMap: restore NRVO in do_take()Marc Mutz7 days1-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The usual problem, the usual solution... At the time of construction of the return object it is known which of the two variables to construct, so NRVO would be permissible, but most compilers don't enable it because the structure isn't T result; // first (non-trivial) variable declared // must be a function's top-level scope ~~~ return result; // only one // or else all return statements are token-by-token the same The usual fix is to wrap the tail part of the function (= the one that constructs a T and returns it, as opposed to the part that returns temporaries) in an IILE expression: the lambda then _has_ said structure, so is NRVO'ed and the call to the lambda is RVO'ed in the caller. Invert the polarity of the if statement in order to keep the meat of the function's git history intact. Amends deddafe0a6a32aa438cc36c7dcfae8c323274487. Pick-to: 6.10 6.8 Change-Id: I3f22665daca320be283e4088cf1062f115cd49e4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QFlatMap: avoid mixing rvalues and lvalues in the ternary operatorMarc Mutz7 days1-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | As pointed out by Coverity elsewhere¹, use of a ternary in return statements can sometimes lead to superfluous copies, because lvalues are forced to materialize an rvalue when they appear together with an rvalue in the resp. other leg. I'm pretty sure that's the case here, because it.value(), while being an lvalue, returns a reference-to-const, so isn't a local object that would enjoy a transparent move, anyway. But by rewriting the code as an if statement instead of a ternary expression, the reader doesn't need to understand the issue (if they are aware of it in the first place): the 'return T()' is definitely RVO'ed, and the return 'it.value()' definitely calls the copy constructor. As the result isn't worse in executable speed, but easier to reason about, do the rewrite. Amends deddafe0a6a32aa438cc36c7dcfae8c323274487 for the original value() and 64bc6509c350c5750c6432a0ae6876f4bfb97cd0 for the is_transparent case. ¹ e.g. cd96362492375c50a9d0614b829c51eb6597d713 Pick-to: 6.10 6.8 Change-Id: Id8b3bc31e0f38ea961cfe6169e68b1b4744c799f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QList: add missing Q_CHECK_PTR in the constructors and in reserve()Thiago Macieira10 days1-5/+18
| | | | | | | | | | | | | Because QArrayDataPointer doesn't. QString and QByteArray constructors do this. resize() already has the macro because it uses QArrayDataPointer::reallocateAndGrow(). squeeze() is untestable. Pick-to: 6.10 6.8 Fixes: QTBUG-142345 Change-Id: I8e7898aed09364f20d1efffdc7ed70a2c152005c Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QFlatMap: use QtPrivate::ArrowProxy instead of own mock_pointerMarc Mutz13 days1-26/+3
| | | | | | | | | | | | .. to use a common vocabulary, and share code. Amends 900d4bd29f30effbb5dbb0efa96886af03839a15, which introduced ArrowProxy for use in QKeyValueIterator and QDomNodeList::It. This is just another user I've overlooked up to now. Pick-to: 6.10 6.8 Change-Id: I2c1eecc75a209ce552ddd1fdebfc6da784c83a00 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QFlatMap: use QT_DEFINED_TAG for OrderedUniqueRangeMarc Mutz13 days1-2/+2
| | | | | | | | | | | | It applies extra safety measures for such tag types. Amends 74a87a329498422db0dea3e469fb84704accbb2b, which ought to have ported this tag struct, too. Pick-to: 6.10 6.8 Change-Id: Idd2c116d1045f4218ec74c52f8ddf00324abd59c Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QFlatMap: remove STL-compatibility guard macroMarc Mutz13 days1-21/+0
| | | | | | | | | | The macro has been silently active since 6.5, with no way to disable it, so remove it now, after two LTS releases have been released with this new default. Pick-to: 6.10 Change-Id: Ibc12fa59707a75eb9e4a452471a83e9df206a7b6 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Android: fix warnings of header qtcore-config_p.h is not used directlyAssam Boudjelthia2025-11-251-2/+0
| | | | | | | | | | This fixes a build error from having multiple redefined macros, and also avoids the warning of: Included header qtcore-config_p.h is not used directly (fixes available) (clangd unused-includes) Change-Id: Ie1575d7dd61d4747be0dc876300063ca3feb9191 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QArrayData: fix exception safety in assign()Marc Mutz2025-11-211-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 Mutz2025-11-211-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 Mutz2025-11-191-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 Mutz2025-11-191-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 Macieira2025-11-181-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 Mutz2025-11-171-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 Dubsky2025-11-141-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 Dubsky2025-11-131-0/+58
| | | | | Change-Id: I6ba6c7090350282c87e618ff603586217adf4221 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QArrayDataOps::assign: improve for forward iterators (redux)Thiago Macieira2025-11-131-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 Macieira2025-11-131-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 Dyomin2025-11-121-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 Dyomin2025-11-121-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 Boddie2025-11-101-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>