summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
Commit message (Collapse)AuthorAgeFilesLines
* Convert all QT_VERSION checks to compare against QT_VERSION_CHECK()Edward Welbourne2021-09-231-3/+4
| | | | | | | The result is generally more readable. Change-Id: I507f67954ecd38516de1b7a6f8244c233ee45ddf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove fatuously true or false QT_VERSION checksEdward Welbourne2021-09-231-15/+1
| | | | | | | | | QT_VERSION is now at least QT_VERSION_CHECK(6, 3, 0), so remove all checks against Qt 6.0.0 or earlier. They are superfluous. Tidied up in some places in the process, particularly #include order. Change-Id: I2636b2fd13be5b976f5b043ef2f8cddc038a72a4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove redundant semi-colonsAllan Sandfeld Jensen2021-09-221-4/+4
| | | | | | | | Causes warnings with clang-cl Change-Id: I57395819debe07aecd045c5a8c747632e6c04fc1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVariant::Private: select storage in get at compile timeFabian Kosmale2021-09-211-1/+1
| | | | | Change-Id: I82b0a7ec28400dac64ea785ba6766ca488e615aa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVariant: write less haphazardly to dataFabian Kosmale2021-09-211-2/+2
| | | | | | | | While the data subobject is at the same position in memory as the QVariant::Private, using d.data actually activates the union member. Change-Id: Ie6879b588c8e830ae8b34cfcd8e9ddff8b60b3a6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProperty: attempt to fix compilation with GCC 10Thiago Macieira2021-09-211-1/+1
| | | | | | | | | | | | Somehow it's not expanding properly in constexpr time. qproperty_p.h:554:30: error: \u2018(QItemSelectionModelPrivate::modelChanged != 0)\u2019 is not a constant expression if constexpr (Signal != nullptr) { ~~~~~~~^~~~~~~~~~ Fixes: QTBUG-96659 Change-Id: I3eb1bd30e0124f89a052fffd16a69d2eb4b45784 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove conditioning on Android embeddedEdward Welbourne2021-09-174-11/+10
| | | | | | | | It is no longer handled separately from Android. This effectively reverts commit 6d50f746fe05a7008b63818e77784dd0c99270a1 Change-Id: Ic2d75b8c5a09895810913311ab2fe3355d4d2983 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QCoreApplication: enforce non-null arguments when sending/posting eventsGiuseppe D'Angelo2021-09-171-5/+18
| | | | | | | | | | | | | | | | | | Passing nullptr as receiver and/or as an event parameter to sendEvent, postEvent, etc. is meaningless. It's also something that users can check for. Therefore, it should not be allowed. Note that the current code already relies on the arguments not to be null, albeit "indirectly" (e.g. they get dereferenced without any null checks). Hence: add asserts that check for non-null in all the relevant codepaths, except for the ones in which there's currently just a warning; for those, add a Qt 7 note. Change-Id: Ia4c58551de88a5d1003f09efa448c1330b6cb122 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QEventDispatcherWasm: handle EventLoopExecMorten Johan Sørvig2021-09-152-0/+19
| | | | | | | | | Call emscripten_set_main_loop like the old GUI event dispatcher did, with one difference that requestAnimationFrame updates are now no longer handled by the event dispatcher. Change-Id: If02d90ae9c45d7b38999567d733a237af842cded Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Q_DECLARE_INTERFACE: rework to use more inline functionsThiago Macieira2021-09-141-7/+19
| | | | | | | | | | That way, we can add the NOLINTNEXTLINE comment to suppress clang-tidy, which otherwise flags all usage of const_cast in C++ code. Change-Id: Ie72b0dd0fbe84d2caae0fffd16a247b96d223772 Reviewed-by: Rui Oliveira Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add documentation for QPropertyBindingErrorFabian Kosmale2021-09-131-11/+146
| | | | | | | Pick-to: 6.2 Change-Id: Ia957cedb4c80cbab956d93c5f1af4d3dd5209089 Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Update some links to Microsoft's documentationLuca Di Sera2021-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documentation links on `msdn.microsoft.com` and `msdn2.microsoft.com` now redirect to `docs.microsoft.com`. Some of the links in the documentation were to those domains. In particular: - An `\externalpage` link to the `Mitigating Cross-site Scripting With HTTP-only Cookies` article. - An `\externalpage` link to `Microsoft Actibe Accessibility Event Constants` - A link to the `RtlGetVersion` function in `qoperatingsystemversion.cpp` - A link to the `GetCommandLine` function in `qcoreapplication.cpp` - A link to the `KNOWNFOLDERID` constant in `qfiledialog.cpp` While the redirection works, our script to catch broken links on dev-snapshots builds of the documentation doesn't handle redirection correctly, reporting it as broken. Both to appease the broken-links script and to avoid an unneccesary redirection, the above links were modified to point to the equivalent address in the new domain. Task-number: QTBUG-96127 Pick-to: 6.2 Change-Id: I0e9a132f06af7fc43bca6c8ad2054feb6e3e27cd Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Allow destruction of QWinEventNotifier in its signalAlex Trotsenko2021-09-101-1/+3
| | | | | | | | | | | | Avoid use-after-free issue in QProcess. Fixes: QTBUG-96285 Fixes: QTBUG-96359 Pick-to: 6.2 6.1 Change-Id: I953d7a8ecaf301ec3a27db37e13748f905c3d097 Reviewed-by: Christoph Cullmann <cullmann@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Fix binding guard in property evaluationIvan Solovev2021-09-101-9/+9
| | | | | | | | | | | The comment for keepAlive means that it should be destroyed after the updateGuard goes out of scope and restores its value. In this case keepAlive should be actually created *before* updateGuard, not after it. Pick-to: 6.2 6.2.0 Task-number: QTBUG-96303 Change-Id: I4f8e67b49c1d6579228e22111105fb936f1f94db Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* normalizeTypeFromSignature: Update for Clang 13Martin Storsjö2021-09-091-2/+1
| | | | | | | | | | | | | | Clang 13 now outputs "unnamed struct" just like GCC, while it earlier used to output "anonymous struct" (since https://reviews.llvm.org/D96807). Therefore, for Q_CC_CLANG check for both "anonymous" and "unnamed". This fixes the QMetaType testcase when built with Clang 13. Change-Id: I34de8c2ca05c0e691fbb990b001f011b0f336dc3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* wasm: add DialogExec hack/warning to event dispatcherMorten Johan Sørvig2021-09-082-0/+19
| | | | | | | | Show the warning (and call emscripten_sleep) for the standard build, but not for the asyncify build. Change-Id: I695a580ea60897872beee6fa2b6ae70acb9e7dcf Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Q_DECLARE_INTERFACE: delete unspecialized qobject_interface_iid()Thiago Macieira2021-09-071-3/+2
| | | | | | | | Instead of making it return a non-useful nullptr. Change-Id: Ie72b0dd0fbe84d2caae0fffd16a245cce5ea65f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Q_DECLARE_INTERFACE: add missing const to const qobject_castThiago Macieira2021-09-071-1/+1
| | | | | | | | | | | | | | [ChangeLog][Potantially Source-Incompatible Changes] The macro Q_DECLARE_INTERFACE used to cast away the constness of the QObject parameter. That is now fixed in this release, but may cause failure to build source code that depended on this incorrect behavior. If fixing the const correctness in your code is not an option, insert an explicit const_cast<IFace *> of the object prior to the qobject_cast call. Change-Id: Ie72b0dd0fbe84d2caae0fffd16a246a36f0c088f Reviewed-by: Rui Oliveira Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove redundant break;s following return;sEdward Welbourne2021-09-061-2/+0
| | | | | | | Pointed out by the INTEGRITY compiler. Change-Id: Id5f9b994c348308c56c3a25200419be525b9c933 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QObject::connect(): fail to connect to a functor if UniqueConnection is passedGiuseppe D'Angelo2021-08-271-7/+26
| | | | | | | | | | | | | | | | | | | | | The connect() documentation makes it clear that UniqueConnection does not work with free functions / function objects and the like; only with actual PMFs. Rather than silently *ignoring* the flag, be vocal about its presence by warning, and make the connection fail (as the user has passed an illegal argument). [ChangeLog][QtCore][QObject] QObject::connect() now will refuse to connect a signal to a free function / function object if UniqueConnection is passed. Note that UniqueConnection has never worked for such connections -- the flag was simply ignored, and they were established multiple times. Now, the flag is not ignored and results in a connection failure (as well as a runtime warning by Qt). Change-Id: I6509667018c74f9bd24910cde0a1b16c5f84f064 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* wasm: add new event dispatcher implementationMorten Johan Sørvig2021-08-272-0/+670
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add QEventDispatcherWasm to QtCore. The event dispatcher supports managing event queue wakeups and timers, both for the main thread or for secondary threads. Blocking in processEvents() (using QEventLoop::WaitForMoreEvents) is supported when running on a secondary thread, or on the main thread when Qt is built with Emscripten’s asyncify support. Code is shared for all both modes as far as possible, with breakout functions which handle main and secondary thread as well as asyncify specifics,. Some functions like wakeUp() can be called from any thread, and needs to take the calling thread into consideration as well. The current asyncify implementation in Emscripten is restricted to one level of suspend, and this restriction carries over to Qt as well. In practice this means we support one level of exec()-like API. Note that this commit does not _enable_ use of the new event dispatcher. This will be done in separate commits. Task-number: QTBUG-76007 Task-number: QTBUG-64020 Change-Id: I77dc9ba34bcff59ef05dd23a46dbf1873cbe6780 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix Clang warning about loop variable creating a copyTor Arne Vestbø2021-08-261-1/+1
| | | | | Change-Id: I2a8b75294ee3bde008bcff37519da087f603ca51 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Fix documentation issues for Qt CoreTopi Reinio2021-08-241-1/+2
| | | | | | | | | | | | | | * Tag deprecated Q(Multi)Map operators in the header to correctly match them with documentation \fn commands. * Add documentation for QByteArrayView comparison operators. * Add a dummy typedef 'jfieldID' for generating docs correctly on non-Android platforms * Fix other minor issues Pick-to: 6.2 Task-number: QTBUG-95860 Change-Id: I141d2f75d6aa10557aa374201f09ad74b4cd6e81 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Re-add QPropertyAlias functionalityFabian Kosmale2021-08-233-12/+40
| | | | | | | | | | | | | | | | | As QPropertyAlias was public by accident in 6.0, we have to ensure that it still works in 6.2. This re-adds some tests for it, and reimplements the unlinking functionality. To avoid performance regressions in hot-paths, a new unlink_fast function is added, which behaves like the old unlink: It ignores the special handling for QPropertyAlias, so that we can skip the tag check. It is only used in QPropertyObserverNodeProtector and clearDependencyObservers, where we already know the type of the observer. Fixes: QTBUG-95846 Pick-to: 6.2 Change-Id: Ifb405b8327c4d61c673b1a912ed6e169d27c2d8f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QMetaEnum: write "proper code"Marc Mutz2021-08-231-27/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rewrite keysToValue() as suggested by a comment: - Don't use the moral equivalent of QString::fromLatin1(keys).split().front().toLatin1(), use QStringTokenizer over QLatin1Strings, removing lots of allocations. - Use QL1S instead of raw char* and strcmp(), because that made the old code rely on NUL-terminated tokens after splitting, which is no longer the case when using QStringTokenizer. - Use the new stringDataView() instead of stringData() to avoid QByteArray dtors littering the code. - Extract Method parse_scope(), using high-level API operating on QL1S to see what it's actually doing, instead of previous low-level bit-pushing with char* and ints that did a good job of obfuscating the purpose of all the scanning. - Extract Method lookup() as a lambda to make the main loop of the algorithm more readable. - Extract Method className() to delay looking up the class name until it is required (and help with readability). This could be further optimized by memoizing the result, but I'm convinced that's not worth the effort. The code now no longer allocates, but we still can't mark the function as noexcept, because stringDataView() contains a Q_ASSERT, so the function has preconditions. Results show that the new code is up to 2x faster than the old, and never slower (within measurement uncertainty): PASS : tst_QMetaEnum::keysToValue(0 bits set) - 0.00042 msecs per iteration (total: 56, iterations: 131072) + 0.00012 msecs per iteration (total: 68, iterations: 524288) PASS : tst_QMetaEnum::keysToValue(1 bits set) - 0.00079 msecs per iteration (total: 52, iterations: 65536) + 0.00024 msecs per iteration (total: 63, iterations: 262144) PASS : tst_QMetaEnum::keysToValue(2 bits set) - 0.0010 msecs per iteration (total: 71, iterations: 65536) + 0.00040 msecs per iteration (total: 53, iterations: 131072) PASS : tst_QMetaEnum::keysToValue(3 bits set) - 0.0014 msecs per iteration (total: 98, iterations: 65536) + 0.00054 msecs per iteration (total: 72, iterations: 131072) PASS : tst_QMetaEnum::keysToValue(4 bits set) - 0.0017 msecs per iteration (total: 57, iterations: 32768) + 0.00074 msecs per iteration (total: 98, iterations: 131072) PASS : tst_QMetaEnum::keysToValue(5 bits set) - 0.0019 msecs per iteration (total: 65, iterations: 32768) + 0.00088 msecs per iteration (total: 58, iterations: 65536) PASS : tst_QMetaEnum::keysToValue(6 bits set) - 0.0022 msecs per iteration (total: 74, iterations: 32768) + 0.0010 msecs per iteration (total: 72, iterations: 65536) PASS : tst_QMetaEnum::keysToValue(7 bits set) - 0.0025 msecs per iteration (total: 85, iterations: 32768) + 0.0012 msecs per iteration (total: 79, iterations: 65536) PASS : tst_QMetaEnum::keysToValue(8 bits set) - 0.0027 msecs per iteration (total: 91, iterations: 32768) + 0.0012 msecs per iteration (total: 85, iterations: 65536) PASS : tst_QMetaEnum::keysToValue(9 bits set) - 0.0029 msecs per iteration (total: 98, iterations: 32768) + 0.0014 msecs per iteration (total: 97, iterations: 65536) PASS : tst_QMetaEnum::keysToValue(10 bits set) - 0.0033 msecs per iteration (total: 55, iterations: 16384) + 0.0018 msecs per iteration (total: 62, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(11 bits set) - 0.0036 msecs per iteration (total: 60, iterations: 16384) + 0.0022 msecs per iteration (total: 73, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(12 bits set) - 0.0036 msecs per iteration (total: 60, iterations: 16384) + 0.0018 msecs per iteration (total: 62, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(13 bits set) - 0.0039 msecs per iteration (total: 64, iterations: 16384) + 0.0021 msecs per iteration (total: 70, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(14 bits set) - 0.0040 msecs per iteration (total: 67, iterations: 16384) + 0.0023 msecs per iteration (total: 77, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(15 bits set) - 0.0042 msecs per iteration (total: 70, iterations: 16384) + 0.0025 msecs per iteration (total: 82, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(16 bits set) - 0.0053 msecs per iteration (total: 88, iterations: 16384) + 0.0028 msecs per iteration (total: 92, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(17 bits set) - 0.0048 msecs per iteration (total: 80, iterations: 16384) + 0.0029 msecs per iteration (total: 97, iterations: 32768) PASS : tst_QMetaEnum::keysToValue(18 bits set) - 0.0050 msecs per iteration (total: 83, iterations: 16384) + 0.0031 msecs per iteration (total: 51, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(19 bits set) - 0.0051 msecs per iteration (total: 85, iterations: 16384) + 0.0037 msecs per iteration (total: 62, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(20 bits set) - 0.0053 msecs per iteration (total: 88, iterations: 16384) + 0.0041 msecs per iteration (total: 68, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(21 bits set) - 0.0056 msecs per iteration (total: 92, iterations: 16384) + 0.0042 msecs per iteration (total: 69, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(22 bits set) - 0.0056 msecs per iteration (total: 93, iterations: 16384) + 0.0044 msecs per iteration (total: 73, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(23 bits set) - 0.0057 msecs per iteration (total: 95, iterations: 16384) + 0.0044 msecs per iteration (total: 73, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(24 bits set) - 0.0060 msecs per iteration (total: 99, iterations: 16384) + 0.0062 msecs per iteration (total: 51, iterations: 8192) PASS : tst_QMetaEnum::keysToValue(25 bits set) - 0.0063 msecs per iteration (total: 52, iterations: 8192) + 0.0048 msecs per iteration (total: 80, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(26 bits set) - 0.000381 msecs per iteration (total: 100, iterations: 262144) + 0.00014 msecs per iteration (total: 75, iterations: 524288) PASS : tst_QMetaEnum::keysToValue(27 bits set) - 0.00616 msecs per iteration (total: 101, iterations: 16384) + 0.0050 msecs per iteration (total: 82, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(28 bits set) - 0.0062 msecs per iteration (total: 51, iterations: 8192) + 0.0051 msecs per iteration (total: 85, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(29 bits set) - 0.0064 msecs per iteration (total: 53, iterations: 8192) + 0.0050 msecs per iteration (total: 82, iterations: 16384) PASS : tst_QMetaEnum::keysToValue(30 bits set) - 0.0062 msecs per iteration (total: 51, iterations: 8192) + 0.0050 msecs per iteration (total: 83, iterations: 16384) Change-Id: Idff1ef7633862beb318901352516ebb0dde3c058 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaEnum: avoid quadratic behavior in valueToKeys()Marc Mutz2021-08-211-5/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QByteArray (thankfully) doesn't have the prepend "optimization", so prepend() is a linear operation, calling it in a loop thus makes the algorithm quadratic. To fix, simply remember the parts in a QVLA (an upper bound on the size of which is easily calculated) and then build the result by reverse-iterating over the QVLA. This join_reversed() function is possibly useful elsewhere, but I left it locally in the unnamed namespace to ease cherry-picking. The new stringDataView() function is more universally useful, too, and will be used in a subsequent other change. It return QL1S instead of QByteArrayView because the latter is scheduled to become a non-string type, and already lacks certain features (e.g. qTokenize() doesn't work on QBA, due to lack of a Qt::CaseSensitivity argument in QBA::indexOf()). It's also a Qt 6 addition, so not available in 5.15. We can revisit this decision later, when QBAV (or, possibly, QU8SV) has caught up. Amends 05e0dfa0060aab80afc696161226b2ab0cddfbf9. Results indicate a ~2x speedup: PASS : tst_QMetaEnum::valueToKeys(1 bits set) - 0.00026 msecs per iteration (total: 70, iterations: 262144) + 0.00017 msecs per iteration (total: 90, iterations: 524288) PASS : tst_QMetaEnum::valueToKeys(2 bits set) - 0.00037 msecs per iteration (total: 98, iterations: 262144) + 0.00019 msecs per iteration (total: 52, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(3 bits set) - 0.00040 msecs per iteration (total: 53, iterations: 131072) + 0.00021 msecs per iteration (total: 56, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(4 bits set) - 0.00047 msecs per iteration (total: 62, iterations: 131072) + 0.00022 msecs per iteration (total: 60, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(5 bits set) - 0.00048 msecs per iteration (total: 63, iterations: 131072) + 0.00024 msecs per iteration (total: 64, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(6 bits set) - 0.00061 msecs per iteration (total: 80, iterations: 131072) + 0.00027 msecs per iteration (total: 71, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(7 bits set) - 0.00063 msecs per iteration (total: 83, iterations: 131072) + 0.00027 msecs per iteration (total: 73, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(8 bits set) - 0.00069 msecs per iteration (total: 91, iterations: 131072) + 0.00030 msecs per iteration (total: 81, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(9 bits set) - 0.00070 msecs per iteration (total: 92, iterations: 131072) + 0.00031 msecs per iteration (total: 83, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(10 bits set) - 0.00074 msecs per iteration (total: 98, iterations: 131072) + 0.00034 msecs per iteration (total: 91, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(11 bits set) - 0.000762 msecs per iteration (total: 100, iterations: 131072) + 0.00035 msecs per iteration (total: 92, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(12 bits set) - 0.00088 msecs per iteration (total: 58, iterations: 65536) + 0.000381 msecs per iteration (total: 100, iterations: 262144) PASS : tst_QMetaEnum::valueToKeys(13 bits set) - 0.00094 msecs per iteration (total: 62, iterations: 65536) + 0.00038 msecs per iteration (total: 51, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(14 bits set) - 0.00099 msecs per iteration (total: 65, iterations: 65536) + 0.00041 msecs per iteration (total: 55, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(15 bits set) - 0.0010 msecs per iteration (total: 67, iterations: 65536) + 0.00042 msecs per iteration (total: 56, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(16 bits set) - 0.0010 msecs per iteration (total: 70, iterations: 65536) + 0.00044 msecs per iteration (total: 58, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(17 bits set) - 0.0011 msecs per iteration (total: 73, iterations: 65536) + 0.00046 msecs per iteration (total: 61, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(18 bits set) - 0.0012 msecs per iteration (total: 79, iterations: 65536) + 0.00048 msecs per iteration (total: 63, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(19 bits set) - 0.0012 msecs per iteration (total: 79, iterations: 65536) + 0.00051 msecs per iteration (total: 67, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(20 bits set) - 0.0012 msecs per iteration (total: 80, iterations: 65536) + 0.00054 msecs per iteration (total: 71, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(21 bits set) - 0.0012 msecs per iteration (total: 83, iterations: 65536) + 0.00090 msecs per iteration (total: 59, iterations: 65536) PASS : tst_QMetaEnum::valueToKeys(22 bits set) - 0.0012 msecs per iteration (total: 85, iterations: 65536) + 0.00057 msecs per iteration (total: 76, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(23 bits set) - 0.0013 msecs per iteration (total: 87, iterations: 65536) + 0.00059 msecs per iteration (total: 78, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(24 bits set) - 0.0014 msecs per iteration (total: 93, iterations: 65536) + 0.00065 msecs per iteration (total: 86, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(25 bits set) - 0.0014 msecs per iteration (total: 94, iterations: 65536) + 0.00063 msecs per iteration (total: 83, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(26 bits set) - 0.00028 msecs per iteration (total: 74, iterations: 262144) + 0.00017 msecs per iteration (total: 94, iterations: 524288) PASS : tst_QMetaEnum::valueToKeys(27 bits set) - 0.0014 msecs per iteration (total: 98, iterations: 65536) + 0.00063 msecs per iteration (total: 83, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(28 bits set) - 0.0014 msecs per iteration (total: 96, iterations: 65536) + 0.00065 msecs per iteration (total: 86, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(29 bits set) - 0.0014 msecs per iteration (total: 98, iterations: 65536) + 0.00064 msecs per iteration (total: 84, iterations: 131072) PASS : tst_QMetaEnum::valueToKeys(30 bits set) - 0.0014 msecs per iteration (total: 97, iterations: 65536) + 0.00064 msecs per iteration (total: 84, iterations: 131072) Pick-to: 6.2 5.15 Change-Id: Ie456b71b39c118001987716e30642f08f5e8dcdb Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaEnum: stop playing ping-pong with *okMarc Mutz2021-08-181-6/+2
| | | | | | | | | | | | By dropping the clause pointlessly guarding the ranged for loop against an empty collection, we can reduce the ping-pong being played with the *ok boolean: Just set it to false at the beginning, and only set it to true when we reach the success-return. Pick-to: 6.2 Change-Id: I87365146086aba427b7414e83f077096824ff56f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaEnum: stop parsing when an invalid key is foundMarc Mutz2021-08-161-1/+1
| | | | | | | | | | | | | | | | The old code obfuscated the algorithm by or'ing -1 into the return value, which is equivalent to setting it to -1 on two's complement architectures (which C++ these days requires), and happily continuing to accumulate potential keys. But nothing that can be or'ed into -1 will ever change the value, so this is rather pointless, as we're not emitting diagnostics apart from setting a bool to false. Fix by simply returning -1. That makes it obvious what we're returning, and we return early on error. Pick-to: 6.2 Change-Id: I8957f44e03609ad58d6c25d5fa78c57190b14bdd Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QVariant: Tolerate QObject* metatypes without QMetaObjectUlf Hermann2021-08-101-3/+5
| | | | | | | | | | QMetaType does. QVariant should do the same. Pick-to: 6.2 Change-Id: I3419276b78b3b5ce8bd144dee92685195797d568 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Daniel Nicoletti <daniel.nicoletti@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QMetaStringTable: disable copy and moveMarc Mutz2021-08-101-0/+1
| | | | | | | | This class is an algorithm, and shouldn't be copied or moved. Change-Id: I6f517f53a242dbfd61975ef885c358eef139a272 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCoreGlobalData: use QHash, not QMap, for dirSearchPathsMarc Mutz2021-08-061-2/+1
| | | | | | | | | No user of the variable iterates over the container, they only manipulate or inspect individual entries, so order doesn't matter. If order doesn't matter, use the more efficient QHash over QMap. Change-Id: Id28913a57bb14eb328e668624f236f76cad86def Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaTypeFunctionRegistry: avoid double-lookup in insertIfNotContains()Marc Mutz2021-08-041-2/+4
| | | | | | | | | | | | | | | | | | Because there's no insertIfNotContains()-like functionality in QHash (unlike std::unordered_map, where insert() doesn't overwrite an existing entry), the code first called contains(k) and then insert(k, ~~~), causing two lookups in the case where the insertion actually happens. Fix by using the pattern QDuplicateTracker's QSet fall-back uses, too: recording the size before and after the call to the indexing operator and using a size increase as the criterion that an insertion should happen. This reduces the number of lookups to one, at the cost of a mapped_type default construction (which, given mapped_type is std::function, should be cheap). Change-Id: I24b31107b3e26f2eea2edce7b46f8cb5e7cb35bf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProperty: Only try to avoid TLS access if currentThreadId is fasterFabian Kosmale2021-08-041-1/+9
| | | | | | | | | | | We will not gain anything if we have to do multiple function calls to obtain the thread id. Therefore we introduce a macro to signal that we have a fast implementation of currentThreadId, and only use the function if it is defined. Pick-to: 6.2 Change-Id: I3347489ea91992896bb753b796ae26e391c2c99c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QProperty: Avoid needlessly refetching bindingStatusFabian Kosmale2021-08-042-9/+12
| | | | | | | | If we already have the bindingStatus, we can just pass it along. Pick-to: 6.2 Change-Id: Iaaea4f4c34e6a786899561293016ece163c26d25 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QProperty: more micro optimizationFabian Kosmale2021-08-042-40/+60
| | | | | | | | | | | | | - Provide an inline version of evaluateRecursive which does not fetch the status. - Provide an unsafe variant of setBindingToNotify which does not set the tag. This can be used in allocateDependencyObserver, as newly allocated observers already have the correct tag (this is checked via an assert). Pick-to: 6.2 Change-Id: I31aec6af4aef244efc6d0777e5bfaaa8f82f2046 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QProperty: Force inlining of addObserverFabian Kosmale2021-08-041-1/+1
| | | | | | | | | | | | | | The method is only called in two places: observerProperty (which only takes care of calling unlink, too, if necessary) and in registerWithCurrentlyEvaluatingBinding_helper. In the first case, the method most likely gets inlined anyway. In the latter case, we really want to avoid the overhead of an additional function call to speed up registration of the property with the binding. Considering that it is an internal method, there is no need to worry about code explosion. Pick-to: 6.2 Change-Id: I3f0f0e37108f3859321d3b432e37fc8da3c15dc0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Pass QBindingStatus to evaluateBindingsFabian Kosmale2021-08-042-12/+11
| | | | | | | | | This avoids another round of TLS lookups in evaluateRecursive when we construct the BindingEvaluationState. Pick-to: 6.2 Change-Id: Icfa9fd81fc6f54623d384c4d3fce33f4d4d549b9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QProperty: micro optimizationsFabian Kosmale2021-08-042-3/+8
| | | | | | | | | | | | | - Ensure that the allocateDependencyObserver fast path is inlined. - Use addObserver instead of observerProperty; we know that a freshly allocated observer does not have its prev pointer set. If prev weren't a private member, we could simply use Q_ASSUME(ptr->prev == nullptr), but making it public or befriending the class seems like a bad idea, as it grants too much access to the internals. Pick-to: 6.2 Change-Id: Ia845f2807c70512563f7b9e1ecb85fe82b66208c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Avoid superfluous QBindingStoragePrivate::get callFabian Kosmale2021-08-041-1/+3
| | | | | | | | | If we have no currentBinding, then registerWithCurrentlyEvaluatingBinding will not do anything. Thus we can completely avoid fetching the storage. Pick-to: 6.2 Change-Id: Ic20142e4c4e09752b5c41b959f66080e6885e6c3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Avoid TLS access for groupUpdateDataFabian Kosmale2021-08-044-7/+23
| | | | | | | | | | | By putting the groupUpdateData pointer into the same thread local as the binding status, we avoid having to fetch two thread_local variables. Moreover, we can reuse the caching mechanism which we have in place for QBindingStatus to avoid costly TLS lookups. Pick-to: 6.2 Change-Id: Iaea515763510daab83f89b8e74f35a80965d6965 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QProperty: Avoid TLS lookup if we are in the same threadFabian Kosmale2021-08-044-1/+18
| | | | | | | | | | | | | | | | | | If the QBindingStatus we receive from the QObject is from the thread which is currently running, we do not need to refetch the thread local; the reason we refetched the thread_local was after all only to guard against the case where a QObject's property gets read in a different thread. To determine whether we are in the same thread, we can store the thread id in the thread_local structure. Currently, it only gets initialized for the main thread in QCoreApplication (as bindings are mostly used there). At a later point, we could either expose initBindingStatusThreadId, or call the function when a QThread gets started. Pick-to: 6.2 Change-Id: Id8eb803973bb083abfab83a62bfccc9e88a4e542 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QMetaType: auto-unregister converters and mutable views againMarc Mutz2021-08-041-8/+37
| | | | | | | | | | | | | | | | | | | | | | | | | The port from hand-rolled function storage to std::function inadvertently removed the helper variable of static storage duration whose dtor would unregister the conversion function. This caused QTBUG-94831, where the cleanup of conversion functions attempts to call code (via std::function) from a library that has already been unloaded. Restore the 5.15 behavior by adding a static-storage-duration scope guard to unregister the conversion and view functions from Qt upon library unload (when static objects are destroyed). Unlike 5.15, only install the scope guard upon successful registration, ensuring that only the DLL which successfully registered its conversion function unregisters it again. Amends 0e4ae4fbf8e320d18c29a55b5db2bba25b3d9d50. Add some strategic std::move()s as a drive-by. Pick-to: 6.2 Task-number: QTBUG-94831 Change-Id: I391ca667420cf0d98a166676b9bb363d6e190306 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Pass QDeadlineTimer by value in runOnAndroidMainThread()Assam Boudjelthia2021-08-011-4/+2
| | | | | | | | Also change the timer default value to use QDeadlineTimer::Forever. Pick-to: 6.2 Change-Id: Ia6d0101872a5d01b04e146cd9b2f90315cb8eb2e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove app permission API from QCoreApplicationAssam Boudjelthia2021-07-304-282/+0
| | | | | | | | | | | | | From the API review session, a potential deadlock behavior might occur when using QFuture's synchronous APIs on the UI thread. Also the fact that this api currently have an implementation only for Android. For those reasons we thought this API could be postponed until Qt 6.3, when the QFuture concern is addressed and other platforms other than Android are implemented as well. Pick-to: 6.2 Change-Id: I1aef025488c24791da85d15fb57367d3e5e681be Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QPrivateSlotBase: add empty base class optimizationMarc Mutz2021-07-291-5/+30
| | | | | | | | | | | | | | | There are few slots whose lambdas are empty; most will at least capture [this]. But there are a few in Qt examples that do, e.g. []{ qApp->quit(); }. Logging is also an example. So go the extra mile and optimize for empty functors by inheriting from them as opposed to storing them in a member variable. Change-Id: I3904f10db5ebe904ba889d29c08569edd804df3b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSlotObjectBase: document relation between m_impl and Operation betterMarc Mutz2021-07-291-1/+4
| | | | | | | Change-Id: I02bfe1857a9c2b781f7ad891e813fd6818fab671 Reviewed-by: Ivan Tkachenko <me@ratijas.tk> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUuid: port fromRfc4122() to QByteArrayViewMarc Mutz2021-07-281-2/+2
| | | | | | | | | Remove the QByteArray overload from the API, but not the ABI. Adapt callers. Change-Id: I88aa09cbca3b89d0b249ce336ebe49c4b352c9e1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QEventDispatcher: Remove code dealing with Windows < 10Mårten Nordheim2021-07-281-13/+1
| | | | | | | It's not supported. Change-Id: I650a48f214bc4965b5e28f04e4f095273d7f9e5b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deduplicate offset calculation in QMetaObjectBuilderIvan Tkachenko2021-07-271-1/+1
| | | | | | | | | | | | Not even an optimization (unless your compiler sucks). Just improves readability, since offset is already calculated few lines above. Offset formula used to be somewhat more complicated, but since commit e58b44d557b859b7b55869f1e137aa1bc8968307 it became reusable here. Change-Id: I4128b2643daf2cb112c9b861342fd0e27c9a1a95 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* macOS: Add helper function to check whether we're running under RosettaTor Arne Vestbø2021-07-272-0/+11
| | | | | | | | As described in https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment?language=objc#Determine-Whether-Your-App-Is-Running-as-a-Translated-Binary Pick-to: 6.2 Change-Id: I16fa4be20e4a55c87c2eb760d671d27ee4de1703 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>