summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qproperty.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QProperty: Use RefCounted as intendedUlf Hermann2024-03-191-3/+3
| | | | | | | | You're not supposed to mess with the refcount directly. That's what the addRef() and deref() methods are for. Change-Id: I5cae946cef7ac72dd99b247ade95590d142c269e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProperty: Destroy binding when refcount is 0Ulf Hermann2024-03-181-7/+0
| | | | | | | | | | This has to be done from all places where we deref it. Otherwise we leak memory. Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-116086 Change-Id: I57307ac746205578a920d2bb1e159b66ebd9b2cc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Merge dangling text with \note paragraphAndreas Eliasson2023-11-131-8/+6
| | | | | | | | | | | | | It's not possible to have empty lines inside a \note as this will cause the text after the empty line to appear outside the note box. So, remove the empty lines to make the note paragraph complete. Also, revise the text. Fixes: QTBUG-117111 Pick-to: 6.6 6.5 Change-Id: I50ad0cd559f684c5264898ef8bbac16910f96dea Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix typo in QUntypedPropertyBinding docsAlexey Edelev2023-08-091-1/+1
| | | | | | Pick-to: 6.2 6.5 6.6 Change-Id: Id279760a40be56bea6456e57404348bd2619f64b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProperty: improve QPropertyAlias deprecationIvan Solovev2023-07-251-0/+2
| | | | | | | | | | | Use QT_DEPRECATED_VERSION_X_6_6 and provide reasons for deprecation for the enum value and for the QPropertyObserver constructor. Pick-to: 6.6 Change-Id: I0f9b4c6dc8bb9fd5eac692a6953c90059f3c77ef Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QBindable: Add doc example for ctor taking property nameFabian Kosmale2023-06-281-1/+8
| | | | | | Pick-to: 6.5 6.6 Change-Id: I36de517291ef940d6fa284e062d44a5b619c0018 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QSlotObjectBase: move the `which` parameter to the 4th positionThiago Macieira2023-05-111-0/+5
| | | | | | | | | | | | | | | | | | | This places the first through third parameters on the exact positions that they will be used to perform the operations in the switch, saving the compiler from generating a few instructions to move data around. All ABIs Qt supports that pass any function parameters in registers at all pass at least 4. We keep the return type as void (instead of returning bool, for the Compare case) so the compiler can apply tail-call optimizations for those two typical cases. PMF case: https://gcc.godbolt.org/z/9oP5boKfj Function case: https://gcc.godbolt.org/z/e9vEzd5dj Functor case: https://gcc.godbolt.org/z/s8Ejjra7P Change-Id: I3e3bfef633af4130a03afffd175d3e3009c56323 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid capturing same property twiceFabian Kosmale2023-04-181-0/+5
| | | | | | | | | | | | | | | | | | | | | | | Avoid capturing the same property multiple times in a binding by storing them in the BindingEvaluationState. We store them in a QVarLengthArray array, as the number of properties involved in a binding is expected to be rather low, so a linear scan is fine. Avoiding double capture is a good idea in general, as we would otherwise needlessly reevaluate bindings multiple times, and also needlessly allocate memory for further observers, instead of using a binding's inline observer array. Even more importantantly, our notification code makes assumptions that notify will visit bindings only exactly once. Not upholding that invariant leads to memory corruption and subsequent crashes, as observers allocated by the binding would get freed, even though we would still access them later. Fixes: QTBUG-112822 Pick-to: 6.5 6.2 Change-Id: Icdc1f43fe554df6fa69e881872b2c429d5fa0bbc Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Update docs to reflect method being renamedAndreas Eliasson2023-03-081-3/+3
| | | | | | | | | The new method has been renamed from markDirty to notify. Fixes: QTBUG-111267 Pick-to: 6.5 6.5.0 6.4 Change-Id: Ib7926a315cfd11ca6930c785290089b7031d34ff Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: fix qdoc warningVolker Hilsheimer2023-03-011-1/+1
| | | | | | | | The \brief of a class documentation needs to end with a full stop. Change-Id: Ia609d7bc6695e785207c0bf4e570a5edeaeaf460 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: <safiyyah.moosa@qt.io>
* Doc: Remove duplicate wordsAndreas Eliasson2023-02-281-1/+1
| | | | | | Change-Id: Ia7a38a1035bd34d00f20351a0adc3927e473b2e7 Pick-to: 6.5 6.4 6.2 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QObjectBindableProperty: Avoid use-after-free in notifyObserversFabian Kosmale2023-02-201-1/+9
| | | | | | | | | | | | | | | | | | | We so far refetched the first observer after evaluating bindings, as binding evaluating might change the list of observers. However, that approach did not take into account that the 'this' pointer might no longer be valid after binding evaluation: In case of a QObjectBindableProperty (or a QObjectCompatProperty), binding evaluation might cause a reallocation of the binding storage, and consequently the invalidation of the QPropertyBindingData. Fix this by refetching the QPropertyBindingData from the storage (if a storage has been provided, which is always the case for the affected classes). Fixes: QTBUG-111268 Pick-to: 6.5 6.4 6.2 Change-Id: Ie7e143a0bbb18f1c3f88a81dd9b31e6af463584f Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Long live QScopedPropertyUpdateGroupMarc Mutz2023-02-101-2/+37
| | | | | | | | | | | | A RAII wrapper around Qt::{begin,end}PropertyUpdateGroup(). [ChangeLog][QtCore][QScopedPropertyUpdateGroup] New RAII class wrapping Qt::beginPropertyUpdateGroup() and Qt::endPropertyUpdateGroup(). Fixes: QTBUG-110710 Change-Id: If2619e9584dd9d57985d63e3babca75421499ab9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProperty: Remove recursive notify logicFabian Kosmale2023-02-081-19/+3
| | | | | | | | | Grouped property updates have been ported to make use of the non-recursive variant, and thus the last remaining user of recursive notify() is gone. Change-Id: I617db0dedc66555152a9b43514d9d8658d528f2c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Avoid accessing deleted binding data in grouped updatesFabian Kosmale2023-02-081-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a use-after-free in QPropertyDelayedNotifications::notify. Before this patch, evaluateBindings or a notify from a property index might have caused the originalBindingData to become reallocated. However, at that point, we've already restored the original bindingData in evaluateBindings, so we won't track updates, and thus won't adjust originalBindingStatus, which will then point to already freed data. To remedy this, we no longer do the notification with data fetched from originalBindingData, but instead use the information we have in the proxyData. We also need to enure that referenced bindings do not get deleted; for that we keep the PendingBindingObserverList alive for the whole duration of the endPropertyUpdateGroup. As we now have the PendingBindingObserverList, we use it for the notification logic, and only notify change handlers in QPropertyDelayedNotifications::notify. That will allow a follow-up cleanup of QPropertyObserverPointer::notify, and aligns the logic for grouped updates with the logic for "nornal", non-grouped updates. Amends f1b1773d0ae636fa9afa36224ba17566484af3cc. Task-number: QTBUG-110899 Pick-to: 6.5 6.4 6.2 Change-Id: Iae826e620d9614b7df39d86d8a28c48c8a5c4881 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Deprecate QPropertyAliasFabian Kosmale2023-02-081-0/+2
| | | | | | | | | | | | | That use case for the class never materialized, and it was actually meant for internal use. However, we put it into the public header, so we cannot remove it (and while undocumented, someone actually used it at some point, compare e4d62651c278c468f71ce097979bc1183ffd0713). Mark it as deprecated instead so that it can be finally be removed in Qt 7. Change-Id: I058c5831a44610121fbec6eaddebd8b33d4a16c9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix proxy-data handlingFabian Kosmale2023-02-071-0/+2
| | | | | | | | | | | | | | | This addresses two different issues: - Firstly, we were casting the resolved binding data pointer to QPropertyProxyBindingData, instead of the d_ptr of QPropertyBindingData. Fix this by introducing a helper function, and consistently using it to access the proxy data. - Secondly, we were not resetting the originalBindingData when the pointed to object was destoyed. Fix that, too. Pick-to: 6.5 6.4 6.2 Task-number: QTBUG-110899 Change-Id: I7691c9df5cc26e761f6b0e5f16d152f7f2183208 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use std::exchange in Qt::endPropertyUpdateGroup()Marc Mutz2023-02-051-3/+1
| | | | | | | | | Easier to read, saying in one line that for which the old code needed three. Task-number: QTBUG-110710 Change-Id: Ie2a1d11aefe0bdf5f4db0694832fce669de564fc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix narrowing in Qt::endPropertyUpdateGroup()Marc Mutz2023-02-051-4/+4
| | | | | | | | | | | | | | | decltype(QPropertyDelayedNotifications::used) is qsizetype, not int, so don't use int to count from 0...used. The notify() and evaluateBinding() functions use their int argument only for pointer arithmetic, so this is completely self-contained. Amends fdedcb6ec650236bef4a8c8f005b5dd24ef7d77a. Pick-to: 6.5 6.4 6.2 Task-number: QTBUG-103532 Task-number: QTBUG-110710 Change-Id: I765a06628d330fbb57a2fbecc96d66690bb62f13 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Remove stale documentation in "qproperty.cpp"Luca Di Sera2023-01-181-29/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | "src/corelib/kernel/qproperty.cpp" documents assignment operators over `QPropertyBinding` for `QProperty` and `QPropertyAlias`. Those operators were removed in 638df6138e7acecc2d3b6aad0771e2d81355f2d2 and are thus stale. Similarly, an assignment operator for `QPropertyAlias<T>` over a `T&&` is documented albeit it was removed in 927647cd032cd2e43bae3184b879586849ffee50. Due an incorrect implementation of QDoc, which has now been removed, with regards to identifying copy/move assignment operators, and the more superficial and incorrect way in which QDoc binds those kind of elements to the clang AST, QDoc was unable to report the lack of a binding declaration for those elements that were removed, producing incorrect documentation instead. As of the latest changes to QDoc this will correctly generate a warning. To avoid the addition of new warnings and remove stale and incorrect documentation, the document blocks were removed from the file. Change-Id: I30e20f26d4c44e4589abf40546d8ebaa4e869638 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QBindable: Make ordinary Q_PROPERTYs bindablePatrick Stewart2022-11-301-0/+176
| | | | | | | | | | | Implements an adaptor from the notification signal of a Q_PROPERTY to QBindable. The Q_PROPERTY does not need to be BINDABLE, but can still be bound or used in a binding. [ChangeLog][Core][Q_PROPERTY] Q_PROPERTYs without BINDABLE can be wrapped in QBindable to make them usable in bindings Change-Id: Id0ca5444b93a371ba8720a38f3607925d393d98a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProperty: Update documentation to reflect eager evaluationFabian Kosmale2022-10-251-159/+182
| | | | | | | | | Amends cf42a0fe5e525efa9a399694cc6882c6e811c286. As a drive-by, reflow the documentation, and mark some code segments with \c Change-Id: Id644e841f9990dd7aec2d7ce74efad8b4472b93a Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Replace qExchange calls with std::exchangeFabian Kosmale2022-09-281-1/+1
| | | | | | | | | | | | | | | | | | | | | qExchange is one of the few remaining functionalities that have not been moved out of qglobal. Given that std::exchange exists in the standard, we can simply move to it everywhere... ...if it weren't for the fact that std::exchange is only constexpr in C++20, and only has its noexceptness specified in (most likely) C++23. Still, we want to move to the existing std functionality where possible, to allow the removal of qglobal includes in lieu of something more fine-grained in the future. So leave any constexpr calls[1] alone for now (and observe that none of our current usages cares about the conditional noexceptness), but replace everything else. [1] QScopedValueRollback' ctor and QExplicitlySharedDataPointerV2::take Task-number: QTBUG-99313 Change-Id: I599cb9846cf319c7ffd3457130938347a75aad25 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Disable constinit for MSVC compilersOliver Wolff2022-08-031-1/+1
| | | | | | | | | | | | | | https://developercommunity.visualstudio.com/t/C:-constinit-for-an-optional-fails-if-/1406069 does not only affect constinit thread_local but also constinit in general on MSVC compilers when C++20 is being used. So disable the feature for these compilers in general for now. This commit amends d9531593a248e19f7da7862b2870a6af2f413e75 Fixes: QTBUG-105234 Pick-to: 6.4 Change-Id: I1855f0857d85487895460fc7c56675fb864bfa73 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProperty: optimize non-recursive notification logicFabian Kosmale2022-08-011-3/+4
| | | | | | | | | | | | Previously, we were storing all binding-observers in a list, so that we can later revisit them during the notification loop. However, there is no point in doing that when the binding did not actually change. Pick-to: 6.4 Change-Id: I0b3343cc442eca2586c7c6a10c31d780f04730e6 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QProperty: Notify observers even when dependency is goneFabian Kosmale2022-08-011-17/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem description: -------------------- Assume we have two properties, P1 and P2. Assume further that we assign a binding to P2, so that it depends on P1. Let the binding additionally capture some (non-QProperty) boolean, and only create the dependency to P1 if the boolean is true. The state afterwards is P1:[p1vaue|firstObserver] | | v ---[p2binding] / P2:[p2value|binding] If the boolean is set to false, and P1 changes its value, we still correctly re-evaluate the binding and update P2's value. However, during binding evaluation we will notice that there is no further dependency from P2 on P1, and remove its observer. The state afterwards is P1:[p1vaue|firstObserver=nullptr] ---[p2binding] / P2:[p2value|binding] Then, during the notify phase, we traverse the observer's again, starting from P1's firstObserver. Given that it is nullptr now, we never reach P2's binding, and thus won't send a notification from it. Fix: ---- We store a list of all visited binding-observers (in a QVarLengthArray, to avoid allocations as long as possible). After the binding evaluation phase, we then use that list to send notifications from every binding that we visited. As we already have a list of all bindings, we no longer need to recurse on binding-observes during the notification process; instead, we only need to deal with static callbacks and ChangeHandlers. The pre-existing notification logic is still kept for the grouped update case, where we already have a list of all delayed properties, and should therefore not encounter the same issue. Unifying its codepath with the existing logic is left as an exercise for a later patch. Fixes: QTBUG-105204 Task-number: QTBUG-104982 Pick-to: 6.4 6.3 6.2 Change-Id: I2951f7d9597f4da0b8560a64dfb834f7ad86e757 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Write QProperty use in QMLJaishree Vyas2022-07-251-0/+11
| | | | | | | | Details: Added a note on how QProperty works in QML using BINDABLE keyword Task-number: QTBUG-89166 Change-Id: Ib48dd26b0724f906efa65d14fbb75a8b97255b05 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid misleading bindingStatusAllan Sandfeld Jensen2022-06-201-0/+1
| | | | | | | | | | | Set it to nullptr on clear, and deal with possibly null bindingStatus. Task-number: QTBUG-101177 Task-number: QTBUG-102403 Pick-to: 6.4 Change-Id: I66cb4d505a4f7b377dc90b45ac13834fca19d399 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QPropertyBindingPrivate: de-inline functions that modify heapObserversMarc Mutz2022-05-171-0/+18
| | | | | | | | | | | | | Manipulating owning containers is costly at runtime, but also at compile-time, so don't do it in inline functions, do it out-of-line. Removes the top-2 entries[1] in a Clang -ftime-trace QtWidget build. [1] at the time of writing of this patch Change-Id: I5da5030788b0d976a0ab7875f87ba3b51dbb1231 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add Q_THREAD_LOCAL_CONSTINIT to work around an MSVC bugMarc Mutz2022-04-011-1/+1
| | | | | | | | | | | | | | | | | | MSVC 19 does not allow using constinit on thread_local objects of non-trivial type: https://developercommunity.visualstudio.com/t/C:-constinit-for-an-optional-fails-if-/1406069 Instead of revoking Q_CONSTINIT for that compiler or removing Q_CONSTINIT from such variables, add a new macro for this situation, so the constinit static assertion will still be checked on other platforms. Amends 32692667a625f31aa02e0303f2139c780ae42694. Change-Id: Ic2247768b0d64e0c01648cffc9532fe5bd4bbd5d Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Apply Q_CONSTINIT across the codebaseMarc Mutz2022-03-291-1/+1
| | | | | | | | | Still not complete. Just grepping for static and thread_local. Task-number: QTBUG-100486 Change-Id: I90ca14e8db3a95590ecde5f89924cf6fcc9755a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProperty: fix threading issuesFabian Kosmale2022-03-101-0/+17
| | | | | | | | | | | | | | | | | | | | QObject's cache the binding status pointer to avoid TLS lookups. However, when an object is moved to a different thread, we need to update the cached pointer (as the original thread might stop and thus no longer exist, and to correctly allow setting up bindings in the object's thread). Fix this by also storing the binding status in QThreadPrivate and updating the object's binding status when moved. This does only work when the thread is already running, though. If it is not running, we instead treat the QThreadPrivate's status pointer as a pointer to a vector of pending objects. Once the QThread has been started, we check if there are pending objects, and update them at this point. Pick-to: 6.2 6.3 Fixes: QTBUG-101177 Change-Id: I0490bbbdc1a17cb5f85044ad6eb2e1a8c759d4b7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Move QBindingStorage methods marked for removal to removed_apiSona Kurazyan2022-02-161-6/+0
| | | | | | | | From the API review. Pick-to: 6.3 Change-Id: I676ff811a3b3d43ebcbee78ed0210d669d642947 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QPropertyBindingPrivate: move static_assert()s to .cpp fileMarc Mutz2022-01-191-0/+5
| | | | | | | | | | | | | | | | | | One of them has managed to percolate up to the top of the Clang -ftime-trace list of expensive template instantiations when building libQt6Gui.so with -pch: **** Templates that took longest to instantiate: 7882 ms: std::is_trivially_destructible<QPropertyBindingSourceLocation> (135 times, avg 58 ms) The checks aren't really necessary, because the compiler would complain about the union's deleted dtor if any of the members were not trivially destructible. Keep it around, though, but in the .cpp file. Task-number: QTBUG-97601 Pick-to: 6.3 6.2 Change-Id: I74a513a907735bde298e0bd9557d10abbcee5c91 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Move Q_OBJECT_COMPUTED_PROPERTY to QObjectComputedPropertyLuca Di Sera2021-11-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | `Q_OBJECT_COMPUTED_PROPERTY` is a macro that is used to declare a `QObjectComputedProperty`. The documentation for the macro was related to the `QObjectCompatProperty` documentation, which is internal. A link to `Q_OBJECT_COMPUTED_PROPERTY` appears in `QObjectComputedProperty`'s page, but fails to resolve as the required documentation page is internal. Furthermore, `QObjectCompatProperty` has a macro that is equivalent to `Q_OBJECT_COMPUTED_PROPERTY`, `Q_OBJECT_COMPAT_PROPERTY`, whose documentation is declared related to `QObjectCompatProperty`. It is hence assumed that relating the documentation for `Q_OBJECT_COMPUTED_PROPERTY` to `QObjectCompatProperty` was a typo, such that the documentation for the macro is now moved to be related to `QObjectComputedProperty`, resolving the linking issue in the process. Task-number: QTBUG-96127 Pick-to: 6.2 Change-Id: I2c1bfd6ba64f13e186c65701593047b64bf0c199 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
* Inline QPropertyBindingDataPointerAndrei Golubev2021-11-011-7/+0
| | | | | | | | | | | | The only non-inline function of that class was observerCount() which would use two of the inline functions defined in the header file, so we can safely inline observerCount() and make the whole class contain only inline methods Consequently, inline class doesn't have to be exported in Windows Change-Id: I41d144d9a50420bbc0091992b36cc36ac2567704 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Extend documentation for bindable propertiesIvan Solovev2021-10-291-4/+9
| | | | | | | | | | | | | Extend the general property system page with a section on how to use bindable properties. Add some cross-references to improve the user experience. Task-number: QTBUG-97656 Pick-to: 6.2 Change-Id: I2520cdc168e3a8a66ea387e4ab717f4e0f969424 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* QObjectComputedProperty docs: move example to snippetIvan Solovev2021-10-261-36/+1
| | | | | | | | | | | This patch amends 89a4c8d40d2ee1b8794dd7fcf80d226c5c87ba6c. It moves the code sample into a separate snippet file, which allows us to use Q_OBJECT macro in it without complaints from moc. Task-number: QTBUG-97656 Pick-to: 6.2 Change-Id: I368d8dd8c00dbbebd8a6bf3788be796c8ca4bce8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make QObjectComputedProperty documentation visibleIvan Solovev2021-10-251-2/+0
| | | | | | | | | | | QObjectComputedProperty belongs to public API. It's even referred in other documentation (for example, QBindable). It does not make sense to have its documentation marked as \internal. Task-number: QTBUG-97656 Pick-to: 6.2 Change-Id: I6ca81292cfafea873dd3577fb0e5ddb583969dc3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Help the compiler avoid duplicate TLS lookupsUlf Hermann2021-10-201-2/+4
| | | | | | | | | Most compilers are clever enough to optimize this out. Yet, even with optimizations disabled, we don't want to do two TLS lookups here. Change-Id: I822954c7cec591084d6c27c916818dab7e000ea9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Optimize QObjectCompatProperty::notifyUlf Hermann2021-10-201-16/+22
| | | | | | | | Do the check for inBindingWrapper() last. Change-Id: I3d589c9fba524f465e35cd4cc0e65e3af376b419 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Inline a few methods of QPropertyObserverPointerUlf Hermann2021-10-181-97/+7
| | | | | | | | This is necessary to optimize QObjectCompatProperty::notify in a second step. Change-Id: I89aaf51d39e04f17285f7db27f9b40d145fd846d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* corelib: Fix typos in documentationJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: I64d63af708bc6ddaabd12450eb3089e5077f849e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* corelib: Fix typos in source code commentsJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 6.2 Change-Id: Ic78afb67143112468c6f84677ac88f27a74b53aa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Use correct \relates targetPaul Wicking2021-10-011-2/+2
| | | | | | | | | | | \relates takes a class name as argument, but doesn't deal nicely with a templates full definition. Pick-to: 6.2 Task-number: QTBUG-97028 Change-Id: I7c608717c5d552bc553073534104dece01b8ff96 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@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: 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-231-9/+34
| | | | | | | | | | | | | | | | | 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>
* 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>