summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
Commit message (Collapse)AuthorAgeFilesLines
* 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. Task-number: QTBUG-96303 Change-Id: I4f8e67b49c1d6579228e22111105fb936f1f94db Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 248f0aad1c4f1c6e7e03ad265c2011390dca75ef) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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 Task-number: QTBUG-95860 Change-Id: I141d2f75d6aa10557aa374201f09ad74b4cd6e81 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 145940e1ef8fc8334ff4603a44f7896886e646cb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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 Change-Id: Ifb405b8327c4d61c673b1a912ed6e169d27c2d8f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit e4d62651c278c468f71ce097979bc1183ffd0713) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMetaEnum: avoid quadratic behavior in valueToKeys()Marc Mutz2021-08-201-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) Change-Id: Ie456b71b39c118001987716e30642f08f5e8dcdb Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit bd52059eef7c96031972b5bee03067f3cb0f038d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Change-Id: I87365146086aba427b7414e83f077096824ff56f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 93745ef34608024db92c90c8e270e441fc346eda) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Change-Id: I8957f44e03609ad58d6c25d5fa78c57190b14bdd Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit db8368f5353494c36aae40d36a214877f5a93940) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QVariant: Tolerate QObject* metatypes without QMetaObjectUlf Hermann2021-08-101-3/+5
| | | | | | | | | | | QMetaType does. QVariant should do the same. 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> (cherry picked from commit 6f8ef8c64d4e7af92f585d10a1d5815fcb67831b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QProperty: Only try to avoid TLS access if currentThreadId is fasterFabian Kosmale2021-08-081-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. Change-Id: I3347489ea91992896bb753b796ae26e391c2c99c Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 5889985c8c8e8cc676de4480ad95979287860b96)
* QProperty: Avoid needlessly refetching bindingStatusFabian Kosmale2021-08-082-9/+12
| | | | | | | | If we already have the bindingStatus, we can just pass it along. Change-Id: Iaaea4f4c34e6a786899561293016ece163c26d25 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 3f0a32aeb50acf17302e44dcffc3210f199de6eb)
* QProperty: more micro optimizationFabian Kosmale2021-08-082-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). Change-Id: I31aec6af4aef244efc6d0777e5bfaaa8f82f2046 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit f7eed15588fc93af417b8969fe4e498936d81e04)
* Pass QBindingStatus to evaluateBindingsFabian Kosmale2021-08-082-12/+11
| | | | | | | | | This avoids another round of TLS lookups in evaluateRecursive when we construct the BindingEvaluationState. Change-Id: Icfa9fd81fc6f54623d384c4d3fce33f4d4d549b9 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit e5aff7f3d9e90860fe24b8fe931a71e115f5413b)
* 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. Change-Id: I3f0f0e37108f3859321d3b432e37fc8da3c15dc0 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 77d528f8d328d43fa367bd4887ad21b5e6b6311e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Change-Id: Ic20142e4c4e09752b5c41b959f66080e6885e6c3 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit b8e1782b670a10fe551669bdce654025acba225f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Change-Id: Ia845f2807c70512563f7b9e1ecb85fe82b66208c Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 5d0095b1c2e60ecfb492c1910df70021128d663c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Change-Id: Iaea515763510daab83f89b8e74f35a80965d6965 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 71fea09e1a8d1fc5d9cca7c504f45b77725c0e21) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Change-Id: Id8eb803973bb083abfab83a62bfccc9e88a4e542 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 460700f7736ae308bcbaa37f512355d09876dc8b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Task-number: QTBUG-94831 Change-Id: I391ca667420cf0d98a166676b9bb363d6e190306 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit fa7f4c5efd91c852341dd2e56396ee3f5fedd33a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Pass QDeadlineTimer by value in runOnAndroidMainThread()Assam Boudjelthia2021-08-021-4/+2
| | | | | | | | | Also change the timer default value to use QDeadlineTimer::Forever. Change-Id: Ia6d0101872a5d01b04e146cd9b2f90315cb8eb2e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 50f53b90220707664947f3d1f9468c466398ec31) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Change-Id: I1aef025488c24791da85d15fb57367d3e5e681be Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 72e5b36e2e4c79dc7995f0203968503266b4f2f5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QEventDispatcher: Remove code dealing with Windows < 10Mårten Nordheim2021-07-301-13/+1
| | | | | | | | | It's not supported. Change-Id: I650a48f214bc4965b5e28f04e4f095273d7f9e5b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit c877e9760bfe6b1493140a2f861232e0ab43d273) Reviewed-by: Oliver Wolff <oliver.wolff@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 Change-Id: I16fa4be20e4a55c87c2eb760d671d27ee4de1703 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit df62fdb51c2cd8746c0fe38b5af4b575cbc2bf00) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Move Android implementation of permissions API to QtAndroidPrivateTor Arne Vestbø2021-07-262-302/+0
| | | | | | | | | | | | | And remove plumbing from public QCoreApplication API, which is going to be removed in follow up patch after leaf modules have moved to the private Android API. The public permissions API will be reintroduced in 6.3 after further work. Change-Id: I46772284b98d0ced8d4a624a850adaa4a1dfe645 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit 5604f633c06585246ba473b209c35db67d68740c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Ensure deprecated APIs in Qt Core are documented as suchNico Vertriest2021-07-232-15/+12
| | | | | | | | | | | Added \deprecated [version_since] when needed Remove references to deprecated functions in \sa statements Fixes: QTBUG-94534 Change-Id: I3b3d4277d63fc5d6d207c28ff2484aed30b83247 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit a2c8184b6b241b063e9af005edf082e653dfd8a6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Android: stop making throwing promisesGiuseppe D'Angelo2021-07-221-25/+1
| | | | | | | | | | | | No Qt API throws exceptions, ever. Kill the throwing paths, leaving the normal paths in which a permission request is denied. Change-Id: I6bebaf155c5232444bf5014e25e9c469d5dccfa6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 21782bdc048a76a8b3f85f7633741f565312f1b6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Simplify the application permission APIAssam Boudjelthia2021-07-193-66/+66
| | | | | | | | | | | | | Remove read/write variants of the permission types to make the API simpler and more versatile. If the user wishes to have more control over the permission requests/checks, they can use more platform-specific code. Task-number: QTBUG-94407 Change-Id: I2b72041aa3effaac7e7f7361237cf1146817b525 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 1969a25ceef1be7b9769245054c80e5b56491820) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Use member function instead of template function to resolve native interfaceTor Arne Vestbø2021-07-171-3/+2
| | | | | | | | | | | | | | | The use of a freestanding function is not needed now that the name doesn't alias the nativeInterface accessor function, and was just adding complexity to the machinery. People not familiar with the code will have an easier time following the flow through the helper member function, and we no longer need to declare our own export macros. Change-Id: I17530b7e89939cfc19ab8ffaa076b7129ae02dcf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 0e7212460ba7fab19a47f960b09a011973a7c475) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Improve error reporting when requesting unsupported native interfaceTor Arne Vestbø2021-07-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By switching out the static_assert for an enable_if we end up producing a clearer error, at the call site: /qt/qtbase/examples/gui/rasterwindow/main.cpp:69:9: error: no matching member function for call to 'nativeInterface' app.nativeInterface<QNativeInterface::QCocoaGLContext>(); ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /qt/qtbase/src/gui/kernel/qguiapplication.h:176:5: note: candidate template ignored: requirement 'NativeInterface<QNativeInterface::QCocoaGLContext>::isCompatibleWith<QGuiApplication>' was not satisfied [with NativeInterface = QNativeInterface::QCocoaGLContext, TypeInfo = QNativeInterface::Private::NativeInterface<QNativeInterface::QCocoaGLContext>, BaseType = QGuiApplication] QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QGuiApplication) ^ By using SFINAE for the TypeInfo we can also ensure that it works for types that are not native interfaces, such as if the user tries to call nativeInterface<QString>(). Since we can no longer use decltype(*this) to resolve the base type we need to change QT_DECLARE_NATIVE_INTERFACE_ACCESSOR to take the type as an argument, as we do for other QT_DECLARE_FOO macros. Change-Id: Ie3f7e01ab7c3eb3dcc2ef730834f268bb9e81e0c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 1ef305de158498ba58063b19a02e40c9f6348857) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QTranslator: Fix loading of meta catalogs from absolute .qm pathKai Köhne2021-07-151-3/+8
| | | | | | | | | | | | | | | | In case of QTranslator translator; translator.load("somedir/file.qm"); and file.qm being a meta catalog file, the sub-catalogs in somedir couldn't be located, unless "somedir" was set as second argument. Fixes: QTBUG-95013 Change-Id: I06103244ce2ff9800c2c64cb0c17f9bc7ef0e8de Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> (cherry picked from commit 85eaae36f6951f03c4aeac50ca826fea5cc088bd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Rename QPermission namespace to QApplicationPermissionAssam Boudjelthia2021-07-146-94/+102
| | | | | | | | | Task-number: QTBUG-94407 Change-Id: Ie9c05dbe498cd372c015b5125e6cb8d59ca96b59 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 07d4ecd73465fba946047610bc2736daa641b8f6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix qt_error_string() and QSystemError::string's lack of i18nThiago Macieira2021-07-081-2/+7
| | | | | | | | | | | | There are four messages that we, for some reason I don't understand, have our own text for instead of using strerror(). But even though they were marked for extraction, they weren't translated. Fixes: QTBUG-95039 Change-Id: I266f1bf9a4d84db39086fffd168f8c6dfe9c2cf4 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> (cherry picked from commit 873119210675c0e38e076c46ec3ecabf9d2ed97e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QProperty: Downgrade assert in noSelfDependencies to warningFabian Kosmale2021-07-071-1/+4
| | | | | | | | | | | | | | | | We call evaluateRecursive_inline in setBinding, which in turns runs the noSelfDependecies check. However, creating a binding resuting in a binding loop must not crash, but instead result in the binding entering an error state. To prevent a crash caused by the assert in debug builds of Qt, we replace the assert with a warning for now. A better approach in the future would be to ensure that we only run the check in cases where we are sure that a self-dependency is really a fatal error. Change-Id: I58158864ed81fa907132a4e7d6667c9b529e7e64 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> (cherry picked from commit fd308819891fdc3c4296050193e97f5d9259501f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QObject: Fix memory leak in queued_activateFabian Kosmale2021-07-061-12/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | queued_activate adds a reference to the slot object. It also attempts to deref it again, but that did not work correctly so far. We could end up with T1 | T2 queued_activate | checks isSlotObject | adds ref | locker.unlock() | | QObject::~QObject | //In disconnect all senders loop | sets isSlotObject to false | derefs slotObj, but not deleted checks isSlotObject | (no deref because it's null) | To solve this issue and others caused by early returns, we now use a RAII helper, which always takes care of calling destroyIfLastRef if the ref count has been incremented. Change-Id: I9c011cdb8faa5f344d7e70f024fc13f407e39ccf Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 44fa80cbd4fabd6d7b87e7a50233f7dbeaf303b4) Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QObject: cleanup the orphaned connection lists on destructionGiuseppe D'Angelo2021-07-061-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a signal/slot connection is broken, it gets added to the sender's list of "orphaned connections", to clean up later. This cleanup happens when the sender gets destroyed or as soon as it emits any signal. This may cause soft memory leaks in case receivers get destroyed, and the sender is a long living object and doesn't emit signals for a while (e.g. QThread). For some reason, an explicit disconnection cleans up the list (either by using the QMetaObject::Connection object, or in case of string-based connect, using a string-based disconnect). This raises lots of doubts about why having this list in the first place. Fix the soft-leak by cleaning up the orphaned connection list when destroying a receiver. Note: I still believe that we shouldn't have any "orphaned" connection list, and rather cleanup on disconnect/deletion (otherwise, emitting a signal may cause a CPU spike because it triggers a cleanup). If we allow for any "impredictability" during signal activation we're just admitting that signals/slots aren't suitable for e.g. low-latency codepaths. That's why I'm not marking the problem as fixed. Original-patch-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Task-number: QTBUG-88248 Task-number: QTBUG-87774 Change-Id: Id25f67a45dff49f740132a44d36e88740eb12070 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit c2839843f23fb5c289175cb9577981d48dd273fc)
* Fix binding functor addressing in QPropertyAndrei Golubev2021-07-051-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | We create the callable object at sizeof(QPBP) offset from the beginning of the memory block. However, evaluateRecursive() uses sizeof() + alignment when fetching that same callable from the memory While on 64-bit platforms this is fine due to sizeof(QPBP) == QPBP::getSizeEnsuringAlignment(), this is broken for 32-bit systems where there's actually alignment bits that follow the QPBP struct in memory (and thus we cast a random memory location to an object) (Note: QPBP is short for QPropertyBindingPrivate) To fix this, change the offset for creation and destruction of the callable to the one that uses alignment. This way, evaluateRecursive() code becomes correct Fixes: QTBUG-93890 Change-Id: Ief57051846632fa61df4b79b3f054c25062a9498 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 565864090d4ca38768c2268ffd265d2f4b49d1b0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Remove temporary alias with typo to corrected PermissionTypeEdward Welbourne2021-07-021-3/+0
| | | | | | | | | | | | It was only needed during the transition, while qtbase integrated the new name, so that qtmultimedia can switch to using it, after which qtbase can safely lose the old name. Task-number: QTBUG-94407 Change-Id: I8e9f35ae04f719fc732cd0fe9501f49b316767e5 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit 7c3198efc2653b35435ffddbe06ed163b757660b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Re-apply "Remove old Android code that have now has alternative public APIs"Assam Boudjelthia2021-07-014-2900/+3
| | | | | | | | | | | | | | This reverts commit 046d819e2e25d2752b3898dd775eeb560e24b4ce. Since qtandroidextras is now removed from qt5, there should no longer be a dependency issue in CI. Change-Id: I3b8ed409eeb0ad6c7bb3303ec08e672739c5b2ed Reviewed-by: BogDan Vatra <bogdan@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 6948c5b3ae255d8a1e0805aaa9b88382a4a445b0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Consistent indentation for all Q_PROPERTYsAndreas Buhr2021-06-251-4/+8
| | | | | | | | | Task-number: QTBUG-94407 Change-Id: I8c97a0b2de2bed78456322be271724fc47479d83 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 1587d75b5e960854be17a017e8fc1cde03ed8058) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Consistent indentation for BINDABLE propertiesAndreas Buhr2021-06-241-1/+1
| | | | | | | | | | Triggered by API review in Gerrit patch 355960. Task-number: QTBUG-94407 Change-Id: I7cafc1cc9d4b929040b53c6bf92c91d73c3b39f2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 4b850065b1631437b65542b3cb1c16077d2f0230) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Coding style: remove redundant braces, break long lineEdward Welbourne2021-06-231-4/+6
| | | | | | | | Task-number: QTBUG-94407 Change-Id: Id9bbc3871bc3350fa5cc656f4248de8e6511ff05 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 9625c744a939d657d5c906ee93d08951fd7732dd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Rename PermisionType to spell permission correctlyEdward Welbourne2021-06-236-13/+16
| | | | | | | | | | Thanks to Giuseppe for pointing it out in API change review. Task-number: QTBUG-94407 Change-Id: I3b8fb653b5efa7ded51f81aadb35d361e7dbf19c Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit ccac1b185abd84e4a1c500bef42961d95f5f882e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Apple: Use POSIX IPC instead of System V in sandboxed applicationsTor Arne Vestbø2021-06-197-10/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | System V semaphores are not supported in sandboxed applications, so when Qt is configured with App Store compliance, or the user requests POSIX IPC explicitly, we use that instead. https://developer.apple.com/library/archive/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW24 As the shared memory name limit on Apple platforms is very low, we have to skip the existing logic for naming, and instead use a truncated hash of the key. This should still be fine for avoiding any collisions in practice. An explicit check for the ENAMETOOLONG error has been added to catch any cases where they key goes beyond the allowed length. Sandboxed applications also have an extra requirement that the key must include an application group identifier. This requirement has been pushed up to the user and documented, as we don't have enough information in Qt to know which identifier to use. Both tst_QSystemSemaphore and tst_QSharedMemory work as before with both sandboxed and non-sandboxed applications, after removing some assumptions in tst_QSharedMemory about System V behavior. Fixes: QTBUG-91130 Change-Id: Iaf1edb36a5d84d69e42ec31471a48d112faa8c6a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 9661cde1615e21f5b6bbffe3e687cacba247f514) Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QEventDispatcherWin32: suppress old {FD_CLOSE|FD_CONNECT} notificationsAlex Trotsenko2021-06-181-3/+10
| | | | | | | | | | | As with other network events, we must also ignore these notifications until WM_QT_ACTIVATENOTIFIERS message is received. Fixes: QTBUG-82835 Change-Id: I0740bf22e8d1cb0e8b4eba7fc1a27ffe669973ff Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit fe6d84d96e67113846801803c3ba1f20b26e123f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBindable: Use setter in setValue for QObjectCompatPropertyFabian Kosmale2021-06-171-0/+31
| | | | | | | | | | | | | Directly writing to the underlying property storage has the potential of breaking all kinds of internal invariants. As we return QBindable in the public interface, we should not grant callers access to the internals of the object. Change-Id: I737ff293b9d921b7de861da5ae23356c17690b78 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> (cherry picked from commit 6b36e783521993df8de6477c789aa26c38803656) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix crash in concurrent disconnectLars Knoll2021-06-172-21/+42
| | | | | | | | | | | | | | | This does not fix all data races that we have in the system yet. One major issue is the virtual disconnectNotify(), that can be called from any thread and thus is inherently problematic, as it can collide with the object getting destroyed at the same time in another thread. Task-number: QTBUG-88248 Change-Id: I9d841eb363b7e4f0de1657aeb8f5340d0fd55190 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 71b4d4f150bc3c904a5aceec37513ddc3cd1c150) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* cleanOrphanedConnectionsImpl: Allow to skip lockingFabian Kosmale2021-06-172-6/+26
| | | | | | | | | | | | This function is/will be used in a few places where we already have a lock. Temporarily unlocking and relocking invites all kinds of troubles. By adding a flag we can instead tell the function that we already hold the lock. Change-Id: Ibca089de61133661d5cd75290f2a55c22c5d013c Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 556fc646cfac4dca43a34f5c4a4f7e6e3ef9104d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* macOS: Detect sandboxed state for command line appsTor Arne Vestbø2021-06-161-2/+2
| | | | | | | | | | | | | The documentation says that if we "pass a URL to the main executable of a bundle, the bundle as a whole is generally recognized.". By passing the executable instead of the bundle we include command line applications that don't have a app bundle folder (but have an embedded Info.plist). Change-Id: I3a2f145c1ec6e16607e9c04baf08678d5dea0b81 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 20f835329a35651c720b73a8d217e3b48ebd2fcf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Revert "Remove old Android code that have now has alternative public APIs"Jani Heikkinen2021-06-164-3/+2900
| | | | | | | | | This reverts commit ff7daa1c33b79d92837c1dca2f55089d8e5dbc80. Reason for revert: Breaks dependency update round now Change-Id: Ie52e9ac189e9516b27df389d6f624b22f939affb Reviewed-by: Antti Kokko <antti.kokko@qt.io>
* Bindable property docs: mention virtual setters and gettersIvan Solovev2021-06-151-0/+25
| | | | | | | | | | | Update the bindable property docs to explain how to deal with virtual getters and setters. Task-number: QTBUG-92994 Change-Id: I6c29011817e83623414b39afee0f39ad4cc5c1c9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit c0716994f3a089b41b5a3d05372f4fc2fb4f51c9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add common internal macros to request jni objectsAssam Boudjelthia2021-06-151-0/+39
| | | | | | | | | | | | | | | | | | | There are multiple macros used to get/check and return with error in case the requested object is not valid. These macros are defined in multiple places and duplicated. This patch defines them in one place and then they can be reused. This macro expects a "char m_qtTag[]" variable to be defined in the scope where the macro is used. That variable is used as a tag for the error message printed when an error occur. Another consecutive patch use the new macros over qtbase code. Change-Id: Ibb8558d1229cec6dad9ec9da6e2635ea54fd18d6 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 01d30e2d5331d0d15516ce3bf7559fcc19b69723) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Remove old Android code that have now has alternative public APIsAssam Boudjelthia2021-06-114-2900/+3
| | | | | | | | | | | * Remove the old qjni private APIs. * Remove the Android permission private APIs. * Remove runOnAndroidThread(). Change-Id: I37ba8b4cb87a099f067e2e0b6744b8d01a0f9bbc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 03eb44394e4cdf3d2a9aa7be632b487313519fbb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>