summaryrefslogtreecommitdiffstats
path: root/src/corelib
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>
* Remove the old qatomicscopedvaluerollback_p.h from QtCoreDocRym Bouabid3 days1-1/+0
| | | | | | | | | | QAtomicScopedValueRollback became a public API in 6.7. ammends 4fa9f13397abf5da44a0fbd70692fa2c8f79ac13. Pick-to: 6.10 6.9 6.8 Task-number: QTBUG-115107 Change-Id: I0d0069b0403ef5109b7f9ead175a18b45b1cea30 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QTZLocale's parsing of non-BMP digitsEdward Welbourne3 days1-10/+23
| | | | | | | | | | | | Digit-parsing wasn't taking into account the width of digits. It thus failed where digits are encoded as surrogate pairs. Expanded a test to expose this failure. Take the width of digits into account. Pick-to: 6.10 Task-number: QTBUG-139223 Change-Id: I0e5497203d6657d04878f06b6a736a57c16edc2f Reviewed-by: Mate Barany <mate.barany@qt.io>
* Build with QT_NO_URL_CAST_FROM_STRINGAhmad Samir4 days1-0/+6
| | | | | | | | | | | Can't mark the whole repo with that macro, because in corelib that would take out the QString conversion operator which is BiC. Add a hard build-time error if QT_NO_URL_CAST_FROM_STRING is defined in corelib, as requested in code review. Change-Id: Ia0e302a2f82b86800e84d15e86ab138f78d45e4d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use Q_ENUM/Q_FLAG instead of Q_ENUMS/Q_FLAGSAhmad Samir4 days1-3/+2
| | | | | | | | | Q_ENUMS and Q_FLAGS have been deprecated since at least Qt 6.0. Task-number: QTBUG-99060 Change-Id: Ia8cbc607c34683dec99587571c0d04f1854e77c2 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qtmetamacros.h: sort out Q_{ENUM,FLAG}* when Q_MOC_RUN is definedAhmad Samir4 days1-1/+3
| | | | | | | | | | | | | | | | | | When Q_MOC_RUN is defined, some Q_ENUM/FLAG related macros are defined as themselves, whereas some other ones are missing. It's not obvious what the exact purpose of having those macros defined when Q_MOC_RUN is defined, but until we know better, add macros that we think are missing from the list. This also fixes a typo (s/Q_FLAGS/Q_FLAG/) from commit 14583137ae445fbfdc82922266f5c0736454f6c4. Pick-to: 6.10 6.8 6.5 Task-number: QTBUG-99060 Change-Id: I096a774baffc05826320af5454563a7825ce064f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* 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>
* QRM: fix build error when using row pointersVolker Hilsheimer4 days1-6/+6
| | | | | | | | | | | Use our begin/end helpers from the Details namespace to iterate over rows, which might be pointers or smart pointers. Simplify by using the namespace, which gives us direct access to the pointerTo helper as well. Amends f9bb6c8d900205375c70bb33f359ce0250212460. Change-Id: I2724d5c83c4c0af85f3141c340ed14683dea74d2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix QRandomAccessAsyncFile::close() logic on macOSIvan Solovev5 days2-23/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The QRandomAccessAsyncFilePrivate::close() function is supposed to cancel all operations and close all the related IO channels, including the main IO channel. The initial implementation had a false assumption that the callback indicating that the main IO channel is closed is always the last callback that is called in this scenario. So, that callback was used to unconditionally call wakeOne() on the condition variable that was used to signal that all operations are completed. However, in practice when we cancel the operations, we receive the following callbacks: * close callback from each IO channel related to each operation; * completion callback for read/write operations with done set to true and error code indicating cancellation; * close callback from the main IO channel. All these callbacks can come in an arbitrary order. As a result, the case when multiple operations are still in progress, and the file is removed (or close() is called) was randomly crashing on CI, because the completion callbacks were trying to access the already-removed file. This patch updates the logic to only wake a condition variable when all callbacks are received. In order to do that we introduce a new m_numChannelsToClose variable to keep track of the number of active channels, and use the size of the m_runningOps set to track the running operations. To verify that the approach works reliably, I manually ran the equivalent of tst_QRandomAccessAsyncFile::fileRemovedInProgress() 100'000 times for each operation (owning and non-owning read/write separately). Amends e6b26ad1eca555ee1e6b2c4e9b4c7676dc754b04. Fixes: QTBUG-141730 Change-Id: I874b9b9999398f787b5039c78bc3d3eee44c088c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Update Apple Clang/LLVM version mapping for Xcode 26.0Tor Arne Vestbø5 days1-1/+3
| | | | | | Pick-to: 6.10 6.8 6.5 Change-Id: Ib88dfd1808bd72155df4d8fb865306413c8c3d91 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* qsimd/x86: Remove detection of RDRND and RDSEEDThiago Macieira5 days4-214/+30
| | | | | | | | | | | | | | | | The previous commit removed their use from QRandomGenerator, which was the only user. This removes their detection too, which means QtCore will not refuse to load when compiled with an -march= flag that specifies the feature should be present, but is missing at runtime. See https://lore.kernel.org/all/9a27f2e6-4f62-45a6-a527-c09983b8dce4@cachyos.org/ Task-number: QTBUG-69423 Task-number: QTBUG-129193 Pick-to: 6.10 6.8 6.5 Change-Id: Ib67da873cc42acfedaeefffd56db0414bb7ea6b0 Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@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>
* Include new languages for CLDR v48Edward Welbourne6 days7-22/+2797
| | | | | | | | | | | | | | | | Include two new languages, Ladin and Shan, and document the various languages and scripts that show up in the cldr2qlocalexml.py output, that I have checked and seen to contain inadequate information. This may make it easier for future updaters to spot new unknown codes when they show up. These are not picked back to past versions because they're naturally documented as [since 6.11] and picking would involve each past branch getting a minor version as its since. Fixes: QTBUG-141949 Change-Id: If0cb3e3b33cd3ce636fd29e904a9ddd617940314 Reviewed-by: Mate Barany <mate.barany@qt.io>
* Fix handling of non-BMP digits in milliseconds fields of timesEdward Welbourne6 days1-4/+5
| | | | | | | | | | | | | | | The code to trim trailing zeros from z (or zz, but not zzz) format correctly checked for whether the text ended with the locale's zero, but incorrectly chop(1)ed to remove the zero, neglecting the possibility that the zero is longer. Noticed while checking where else we used QLocale::zeroDigit() possibly naively. Add Fulah-Adlam tests for milliseconds, which confirmed the problem does actually appear. Fix dropping of trailing zeros from millis. Pick-to: 6.10 6.8 6.5 Change-Id: Id080f082b2890a102809ba8d0f687d55ac082357 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Tweak QTZLocale's parsing of offsets to pretend "GMT" == "UTC"Edward Welbourne6 days1-1/+14
| | | | | | | | | | This is needed to match kludges already present in QUtcTZP::displayName(), which needs to do this to respect locale zone offset forms. Task-number: QTBUG-139223 Change-Id: I367413817e4824e3e5dbe0c73d8d6b36dfc1bf64 Reviewed-by: Mate Barany <mate.barany@qt.io>
* Do some minor tidy-up in qtimezonelocale.cppEdward Welbourne6 days1-6/+11
| | | | | | | | | | | | | | Its OffsetFormulaMatch::operator bool() was missing const-qualification; supply it and use it. Combine an indexOf() and the check of its return into an if condition. Split up an if-else chain where an early return made else redundant. Add notes with links to help clarify what's going on with some of the formatting details. Pick-to: 6.10 6.8 Task-number: QTBUG-139223 Change-Id: Ie235641c3086965aeb631588c55ec38a554a08e0 Reviewed-by: Mate Barany <mate.barany@qt.io>
* wasm: run the current test by defaultMorten Sørvig6 days1-1/+1
| | | | | | | | | Make the test runner run the current test by default in non-batched mode, without requiring a testname parameter. Change-Id: Ia74f5a3db4a5c4a8d9f6a41073520653781d0f17 Reviewed-by: Lorn Potter <lorn.potter@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Partially revert "qnumeric.h: add support for C23/C++26 <stdckdint.h>"Thiago Macieira6 days1-33/+9
| | | | | | | | | | | | | | | This reverts commit 08ebe3465cc2fce98662b5833b75503490f66265. Reason for revert: the ckd_* functions are not constexpr. If we're going to have to keep our implementations anyway, then we may as well skip using the C23/C++26 feature. Maybe in C++29 they become constexpr. I've left behind the requirement to not use plain char, in case we want to switch to these later. That retains the old commit's changelog. Fixes: QTBUG-142028 Change-Id: I6db786946ae31be16891840b03e5120eb8915d52 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>
* CMake: Fix rcc big resource feature in in-tree example buildsAlexandru Croitor7 days1-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | qt6_add_big_resources creates a helper object library using _qt_internal_add_rcc_pass2 and disables AUTOMOC and AUTOUIC for it. qt_examples_build_end collects all targets created in the examples subdirectory, an enables AUTOMOC and AUTOUIC for them, to avoid some top-level build issues. If an example uses qt6_add_big_resources, then during an in-tree example build, AUTOMOC is re-enabled for the helper object library. That causes build errors due to $<TARGET_OBJECTS:obj_lib> usage in _qt_internal_add_rcc_pass2 expanding also to a mocs_compilation.cpp file and passing a semicolon separated list to rcc --temp option. Set a _qt_internal_is_rcc_pass2_obj_lib property on the object library, and skip re-enabling AUTOMOC and AUTOUIC for it when querying for in qt_examples_build_end. This allows using qt6_add_big_resources in examples without causing build errors. Pick-to: 6.8 6.10 Change-Id: Ib22f77b683757f0981b3ab788edb63bb9e74f67a Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Update CLDR to v48Edward Welbourne7 days8-186017/+195651
| | | | | | | | | | | | | This is just the plain upgrade without adding new languages. It required two changes to expected data in tests. [ChangeLog][QtCore][Third-Party Code] QLocale now uses v48 of the Unicode Consortium's Common Locale Data Repository (CLDR). Pick-to: 6.10 6.8 6.5 Task-number: QTBUG-141949 Change-Id: I8d3a299c602e6cd5ea76c6bc479028aeda8b8e50 Reviewed-by: Mate Barany <mate.barany@qt.io>
* Remove redundant Q_FLAGS usage from two private classesAhmad Samir8 days1-1/+0
| | | | | | | | | Both classes don't inherit from QObject, so the Q_FLAGS macro doesn't register anything with the meta-object system here. Task-number: QTBUG-99060 Change-Id: Id25f8b92cfe6eeade28059f5f7c661603f08e863 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QString: fix docs, QChar::unicode() returns char16_tAhmad Samir8 days1-2/+2
| | | | | | | | | | Pointed out by Marc in code review. Drive-by, use \c to markup ushort. Pick-to: 6.10 6.8 6.5 Change-Id: I81e9997bd07d3c8e4093f42b3a9c2068d8ba4e6e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix build with disable-deprecated 6.6: QList is forward-definedThiago Macieira8 days1-0/+2
| | | | | | | | | | | | qtbase\src\corelib\compat\removed_api.cpp(763): error C2027: use of undefined type 'QList<QString>' qtbase/src/corelib/tools/qcontainerfwd.h(40): note: see declaration of 'QList<QString>' qtbase\src\corelib\compat\removed_api.cpp(1307): error C2027: use of undefined type 'QDynamicMetaObjectData' qtbase/src/corelib/kernel/qobject.h(43): note: see declaration of 'QDynamicMetaObjectData' Pick-to: 6.10 6.8 Fixes: QTBUG-141994 Change-Id: I63324a2cc3b89c62d9ecfffd07b7b82e4ea72641 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* qtdeprecationmarkers.h: add a comment on why we #undefMarc Mutz9 days1-0/+1
| | | | | | | | | | Not understanding these #undefs blocked me for some time while trying to introduce QT_DEPRECATED_MACRO, so make sure the next reader gets a head-start. Pick-to: 6.10 6.8 6.5 Change-Id: I77afe04beee00c1a4db65e5c160d052946f89f0a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Enable support for QFile::moveToTrash() on iOSTor Arne Vestbø9 days1-11/+0
| | | | | | | | | | | | The platform nowadays has support for moving files to the trash. Doing so will make the file available under "Recently Deleted" in the Files app. Pick-to: 6.10 Task-number: QTBUG-120528 Change-Id: I38d1115d96eb6df8512f0165db93af5c1c8b595b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@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>
* QFileSystemEngine/Win: use qEnvironmentVariable instead of qgetenvMate Barany10 days1-5/+5
| | | | | | | | | It returns a QString immediately so there is no need for additional conversions. On Windows, it is also lossless. Pick-to: 6.10 Change-Id: I672d362116551a578c9eb111dd56785893de22be Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QThread/Unix: intercept exceptions only with GlibcVladimir Belyavsky10 days1-9/+11
| | | | | | | | | | | | | | | | | See 5677b70eee2e923eea8e5150500ac745d8d54974 for details why we need such specific exception handling for Glibc. In short, on Glibc, pthread_cancel and pthread_exit are implemented by throwing a special kind of exception that can be caught, but must always be rethrown. That exception is then used to activate the cancellation clean-up handlers. But for libc++ on Apple platforms we can simply wrap it as noexcept to guarantee that std::terminate() will be called in case of any unhandled exception. Task-number: QTBUG-141803 Pick-to: 6.10 6.8 Change-Id: Iaa88d3a8091425206ee2735e835ae74fd087e9e0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRM: report the number of properties as column count in trees of gadgetsVolker Hilsheimer10 days1-8/+11
| | | | | | | | | | | | | | | | | | Instead of hardcoding the column count to 1 for one-dimensional ranges, use the row traits's fixed_size attribute, which reports the number of properties for rows that are gadgets. This was already correctly done for tables. To remove duplication, move the structure-independent part of the logic into a reusable helper in the base class. Add basic test coverage. Fixes: QTBUG-141885 Pick-to: 6.10 Change-Id: Ic10a8a61998184485acb89ca9db0d9c9be822f2d Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* QString::assign: mark the projection lambda noexceptMarc Mutz11 days1-1/+1
| | | | | | | | | | | | | | | | As mentioned in QTBUG-141899, we were not considering the projection itself can throw when designing exception safety in QArrayDataOps::assign(). The fix will be to inspect the projection for noexcept'ness, and, failing it, take a slower path. To prevent that from pessimizing QString::assign(), mark the projection lambda as noexcept. Amends f5ed163c19c4a165a61e6fbfdaf5ee39b5587a0c. Task-number: QTBUG-141899 Pick-to: 6.10 6.8 Change-Id: I14f798398cf0e59cfbb167994f66e802d6271e1a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 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>
* qtmetamacros.h: fix comment of two #endifAhmad Samir11 days1-2/+2
| | | | | | | It starts with `#ifndef QT_NO_META_MACROS`. Change-Id: Ibd065b7b3432d1b8e6ab81e913c09bdcddc5173f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qtmetamacros.h: remove redundant Q_PRIVATE_QPROPERTYAhmad Samir11 days1-4/+0
| | | | | | | | | It was removed in commit e6988d4d0bef2c3f474576250cb305a2f00a688b. Pick-to: 6.10 6.8 6.5 Change-Id: Ia376c11cb8ace52472260cbde6424b9d1c082c97 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qtmetamacros.h: don't use Q_ENUMS/Q_FLAGS in {Q_ENUM,Q_FLAG}{,_NS}Ahmad Samir11 days1-4/+4
| | | | | | | | | | | | Q_ENUMS and Q_FLAGS have been deprecated since at least Qt 6.0. Since the behavior doesn't change at all, pick it to stable branches to reduce git merge conflicts for backports. Pick-to: 6.10 6.8 6.5 Task-number: QTBUG-99060 Change-Id: Ib4153897b3e178d810627ab2a54f72b202a6b06b Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QRandomGenerator: remove direct use of HW instructionsThiago Macieira11 days2-6/+2
| | | | | | | | | | | | | | | | | | | | | The HWRNG instructions are not necessarily faster than what we can get from the OS. Moreover, the OS is able to collect entropy from sources other than the CPU itself. More importantly, this removes the need for Qt to deal with broken HWRNG, passing the buck to the OS (which may disable the CPUID bit, causing the application to fail to load). [ChangeLog][QtCore][QRandomGenerator] This class no longer directly uses a hardware random number generator on x86 systems, even if one is available. Instead, it will always use a generator provided by the OS (so performance will be OS-specific), though there should be no meaningful difference in the quality of the samples generated. Task-number: QTBUG-69423 Task-number: QTBUG-129193 Pick-to: 6.10 6.8 6.5 Change-Id: I5121c5a34d684983fa1dfffdbabd22de51966650 Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@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 days3-213/+243
| | | | | | | No functional changes. Change-Id: Iacbae1e04d9a9edd35acce17fd7ecf268fbe9340 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QRangeModel: implement autoConnectPolicyVolker Hilsheimer12 days3-15/+534
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A model that operates on a range holding items of the same QObject subclass presents the values of the properties of those QObject instances as its data. The property names will be used as the role names. It is then very convenient if changes to the properties in those QObject instances makes the model emit dataChanged() for the respective index and role. This requires that we identify the changed-signals for each property that corresponds to a role name, and connect to each of those signals for each object instance. This is an expensive operation, in particular for trees where we have to recursively traverse the entire sturcture. But a range holding QObjects is already quite expensive and therefore only reasonable for small models with dozens rather than thousands of items. At that scale, the overhead is acceptable, and we can store the respective meta data in a baseclass of our storage type, specialized for when the range's item type is the same QObject subclass for all columns. We know this already, as the default implementation of roleNames() uses that as well. Each connection goes to a functor object that stores the index and the role, which is the information we need to emit dataChanged. By storing the index as a QPersistentModelIndex, objects changing position in the model will automatically update the functor object. The public API for this is a policy property, with two values (plus the "None" default value): a Full auto connect iterates the entire model and connects all relevant properties. This is expensive compared to only connecting some objects and properties, but gives full coverage, and has no overhead other than the connection itself. The alternative is OnRead, which connects lazily when data is read for the first time. This is cheaper if it's unlikely that all objects and/or all properties are displayed, but adds book-keeping overhead so that we know when an object and role are already connected. If everything gets connected lazily, then this is substantially more expensive than doing a full auto-connect in the first place. When new rows or columns got inserted, and if autoConnectionPolicy is set to Full, then we need to connect the new objects after QAIM emitted rows/columnsInserted(). This gives clients a chance to populate the new cells with objects. When rows or columns are removed and the policy is set to OnRead, then we have to remove those connections from our book- keeping set. When objects are removed from the model (which means rows or columns are removed), then we need to break the connection to the respective objects. As the QObjects will likely be destroyed anyway, which will then break the connections, we disconnect lazily: we disconnect if our functor gets called for an object that has been removed. In that case, the stored QPMI will have become invalid. To break the connection, we need to store the QMetaObject::Connection in the functor object. However, we only get that connection handle as a result of making the connection, at which point our functor object has already been moved into Qt's QCallableObject data structure. In order to store the connection handle, we implement the move constructor of the functor to store the address of the move-constructed functor object in the moved-from functor object. This makes a moved-from functor act as a reference to the moved-to functor and we can use that to store the connection handle in the functor instance that is stored in the QCallableObject. Since a functor instance holds either the property data, or the address of the moved-to instance, we can use a std::variant to avoid overhead. Using a plain union would be even cheaper, but at this point, benefit from the guard-rails we get from std::variant. The context object for all connections is then a dedicated QObject, which we can simply delete to break all connections. [ChangeLog][Core][QRangeModel] A range model operating on a range that holds identical QObject sublasses for all items can now automatically connect the changed signals of all properties mapped to item roles to the model's corresponding dataChanged signal. This allows user code to change properties of the item-object directly, and model clients (like item views) will get updated. Change-Id: I742b57f0c90f705d8b7eb949ff0d026b8b4a52f3 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* QVariant: remove pointless castMarc Mutz12 days1-1/+1
| | | | | | | | | | | | | | | | Placement new wants to be called with a void* (cf. VOIDIFY() in std::construct_at()'s definition), so stop there, don't continue to cast to char*. This was already done for the primary overload of the in-place constructor, but forgotten in the initializer_list one. Amends c81e8f8ff24d30cc4c137d6f071954958e984ce9. Pick-to: 6.10 6.8 Change-Id: I5fe43d0062f2ad5e88603d5d231c2053f1164fed Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* [docs] Q_CONSTINIT: mention it attaches to definitionMarc Mutz12 days1-0/+12
| | | | | | | | | | | | | | | | | | | | The macro (like the attributes and the C++20 keyword that back it) belongs on the definition, not on the declaration, of the variable, because it's a static assertion on properties of its initialization. Some compilers apparently accept it on a non-defining declaration (or we only checked in C++17 builds with old compilers), but we have several variables in QtCore that are marked as described in this documentation addendum, and they've not caused problems in the CI all these years, so document as practiced, and ignore other combinations that theoretically may work, too (on some compilers, at least). Amends 80b6bcc385863a38d499685af9b8e857e46cbdba. Pick-to: 6.10 6.8 6.5 Change-Id: I825127ff9ade483584f399fda78b7c7082f68ed8 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Fix or remove self-referencing "see also" linksDavid Boddie13 days2-3/+3
| | | | | | | | | | 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>
* Strict mode: add a note about updating the docs when adding to the listAhmad Samir2025-11-091-1/+4
| | | | | Change-Id: I451b540940bce98ae09c2855cd2b86ff9ba9bb2f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove redundant self-reference in QDateTime::TransitionResolution docEdward Welbourne2025-11-071-1/+1
| | | | | | | | | Its \sa to itself is superfluous. Amends commit a49ccc08c307b7c7e1acc34752b81dd38ea43bfa (6.7). Pick-to: 6.10 6.10.1 6.8 Change-Id: If7ddd8b654c2f6076a4941aa25a020c7538537a6 Reviewed-by: David Boddie <david.boddie@qt.io>
* QCoreApplication: use unique_ptr in PermissionReceiverMarc Mutz2025-11-071-1/+1
| | | | | | | | | | | | | ... not shared. Amends 0bd1fc006097e481d8b92ee1c5246ffa1ae9379f, which removed the need for SlotObjSharedPtr, but didn't adjust the data member. Pick-to: 6.10 6.8 Change-Id: If5991d20b091271f9e38e2f621eb62020cee9871 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* macOS: Check entitlements directly for app sandbox detectionTor Arne Vestbø2025-11-071-46/+4
| | | | | | | | | | | | | | | Checking entitlements via the code signing verification machinery of SecStaticCodeCheckValidityWithErrors is potentially slow (may even reach out to the network, in some cases). We were mitigating this by spinning up a short lived thread to resolve the state before it was needed, but pulling the sandbox state out of the entitlements directly removes all this complexity, and is 4x faster for those times we would end up blocking waiting for the thread to finish (3-4ms vs 20ms). Pick-to: 6.10 6.8 Change-Id: I069b5bb576464b6add92dc9d37fdf116f3553d0c Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>