summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qproperty_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Inline QPropertyBindingDataPointerAndrei Golubev2021-11-011-4/+12
| | | | | | | | | | | | 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>
* Optimize QObjectCompatProperty::notifyUlf Hermann2021-10-201-9/+16
| | | | | | | | 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>
* QObjectCompatProperty: Add support for custom gettersIevgenii Meshcheriakov2021-10-201-8/+28
| | | | | | | | | | Add additional template argument to QObjectCompatProperty to specify a custom getter. This may be useful for classes like QAbstractProxyModelPrivate the need to customize property getters. Task-number: QTBUG-89655 Change-Id: I34fe4bdebbbf1446aff60bd20a946454607f52d5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Disable copy and move for QPropertyObserverNodeProtectorUlf Hermann2021-10-191-1/+4
| | | | | | | It's not intended to be copied or moved and static analysis complains. Change-Id: I2ac2eccadb66ea572cf297f16af693b15553a1b9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Inline a few methods of QPropertyObserverPointerUlf Hermann2021-10-181-2/+104
| | | | | | | | This is necessary to optimize QObjectCompatProperty::notify in a second step. Change-Id: I89aaf51d39e04f17285f7db27f9b40d145fd846d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProperty: Eliminate further unnecessary TLS operationsUlf Hermann2021-10-181-6/+6
| | | | | | | | | If we don't have a binding, we don't need to remove it. We can figure this out without TLS lookup. Pick-to: 6.2 Change-Id: I0cb20f2a68a119df7742631e307002e3813eac03 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProperty: Don't needlessly calculate inBindingWrapper()Ulf Hermann2021-10-181-14/+14
| | | | | | | | | If there is no binding data, we don't need it. inBindingWrapper() involves a TLS lookup. Pick-to: 6.2 Change-Id: I829f314d708b80821e907124eef4aec758bbbc6a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* 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>
* 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>
* Re-add QPropertyAlias functionalityFabian Kosmale2021-08-231-1/+2
| | | | | | | | | | | | | | | | | 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: Avoid needlessly refetching bindingStatusFabian Kosmale2021-08-041-3/+3
| | | | | | | | 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-041-0/+46
| | | | | | | | | | | | | - 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-041-2/+2
| | | | | | | | | 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-041-2/+7
| | | | | | | | | | | | | - 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 TLS access for groupUpdateDataFabian Kosmale2021-08-041-1/+1
| | | | | | | | | | | 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-041-0/+1
| | | | | | | | | | | | | | | | | | 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>
* 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. Pick-to: 6.2 6.1 Change-Id: I737ff293b9d921b7de861da5ae23356c17690b78 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
* Simplify storing of notification objectsLars Knoll2021-06-011-0/+7
| | | | | | | | | | | | | | | | | | | | QPropertyChangeHandler is a templated class and it's argument is a functor. That makes it inherently cumbersome to use the class in any context where the change handler needs to be stored. Introduce a QPropertyNotifier class that stores the functor in a std::function<void()>, and add a QProperty::addNotifier() method that can be used instead of onValueChanged(). Also make QPropertyNotifier default constructible. This significantly simplifies the code that needs to be written and makes it possible to store notifications as class members without major hassle. Fixes: QTBUG-92980 Change-Id: Id5b7baec093b9ac0467946cded943d92ad21030b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* gcc 11: Adjust pragma warning placementFabian Kosmale2021-05-251-0/+8
| | | | | | | | | | | Apparently, gcc's pragma warning logic has changed from 10 -> 11. For gcc 11, we need to place the macro directly next to the the line which triggers the warning. Task-number: QTBUG-93360 Pick-to: 6.1 Change-Id: Ifaa6136050fe5b887660a8a0acf6938388f4f77d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProperty: Cleanup QPropertyAlias leftoversFabian Kosmale2021-05-111-1/+0
| | | | | | | | | | | | | | | This removes traces of QPropertyAlias which is internal API which is a) not really working even before this change (no compatibility with QBindableInterface due to QPropertyAlias not being derived from QUntypedPropertyData) b) not used anywhere For BIC reasons, we need to keep some methods still around until Qt 7, though. Change-Id: I5bb4735a4c88cba275dc2cc6e29a46ca09622059 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Tweak naming of QT_OVERLOADED_MACRO variantsTor Arne Vestbø2021-05-041-6/+6
| | | | | | | | Add a _ suffix before the number of arguments, to improve readability of the argument-specific functions. Change-Id: I1dfc4f381450825dd143ece524bb10e117c09971 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QUntypedBindable: Allow controlled access to internalsFabian Kosmale2021-05-041-0/+13
| | | | | | | | | | In declarative, we need direct access to the bindable's pointers. Enable this via a internal only helper struct in qproperty_p.h. Change-Id: I56e4622f570ff08f85f1161af608658ea510671e Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QPropertyBinding: Add sticky modeFabian Kosmale2021-04-161-0/+8
| | | | | | | | | | | A sticky QPropertyBinding is a binding that does not get removed when a write occurs. This is used in the QML engine to implement support for the QQmlPropertyData::DontRemoveBinding flag. Task-number: QTBUG-91689 Change-Id: Ib575b49abe634215318ccc7ba46212cc21eb4dad Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add support for grouped property changesLars Knoll2021-04-161-18/+24
| | | | | | | | | | | | | | | | Add Qt::begin/endPropertyUpdateGroup() methods. These methods will group a set of property updates together and delay bindings evaluations or change notifications until the end of the update group. In cases where many properties get updated, this can avoid duplicated recalculations and change notifications. Change-Id: Ia78ae1d46abc6b7e5da5023442e081cb5c5ae67b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Don't emit change notifications more often than requiredLars Knoll2021-04-161-1/+9
| | | | | | | | | | | | | | | | When a property value changes, first update all dependent bindings to their new value. Only once that is done send out all the notifications and changed signals. This way, if a property depends on multiple other properties, which all get changed, there will only be one notification; and (potentially invalid) intermediate values will not be observed. Fixes: QTBUG-89844 Change-Id: I086077934aee6dc940705f08a87bf8448708881f Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Address thread safety issues in QProperty classesFabian Kosmale2021-04-161-3/+7
| | | | | | | | | | | | | | | | While we do not support cross-thread bindings, reading of properties from a different thread when no bindings are involved must continue to work. However the check whether bindings are involved used the QBindingStatus in the QObjectPrivate. That one contains the wrong value when the QObject is accessed from a different thread than the one it has affinity with. This patch reads from the thread_local directly instead to sidetstep the issue. Change-Id: I8ce2092f35e210566934e2439beb5d48fd8cf226 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>
* Remove lazy binding evaluationLars Knoll2021-04-161-31/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Too much of the existing code in Qt requires eager evaluation without large scale modifications. Combined with the fact that supporting both eager and lazy evaluation has a high maintenance burden, keeping lazy evaluation, at least in its current state, is not worth it. This does not diminish other benefits of the new property system, which include - a C++ API to setup and modify bindings and - faster execution compared to QML's existing bindings and the ability to use them without having a QML engine. We do no longer benefit from doing less work thanks to laziness. A later commit will introduce grouping support to recapture some of this benefit. [ChangeLog][Import Behavior Change][QProperty] QProperty uses always eager evaluation now when a dependency in a binding changes. Change-Id: I34694fd5c7bcb1d31a0052d2e3da8b68d016671b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Fix Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS when using the signalIvan Solovev2021-04-031-4/+4
| | | | | | | | | | This commit amends 4ceaf22bed1bc0ed2dec4628fd9d9814c0e0fd86. Signal parameter was not actually used, even is the signal was specified. This patch fixes it and also introduces unit-tests for this issue. Change-Id: I029d413644eb6a72af3bdce27cc5f5bcadfe946a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QObjectCompatProperty: Reintroduce operator=Fabian Kosmale2021-04-011-0/+6
| | | | | | | | | | This is a partial revert of a1a2d97e34eb7e2445877cf9e557db55a3540f9d. Reason: The new design does not notify automatically anymore, so using operator= is safe to use. Change-Id: I6cb735e40c0da72d22fcc426423eb7830901e5f4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QObjectCompatProperty: Emit signal in notfiyFabian Kosmale2021-04-011-11/+48
| | | | | | | | | There is no need to write emit and notify at the same time, as not emitting after notify does not make sense. This naturally only applies to properties with a changed signal. Change-Id: I99ff7863a509262ad9d4f7c9c5afbc66fd37001c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QObjectCompatProperty: Require explicit notifyFabian Kosmale2021-04-011-5/+0
| | | | | | | | | | For QObjectCompatProperty, which allows to do basically anything in its setter, it is actually easier to manually specify when the change should become visible. This is in line with manually writing emit calls in the old property system, and allows the preservation of class invariants. Change-Id: I585bd3f25d722ca3fd721ead85fe73dbee26c5f6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove outdated commentAndreas Buhr2021-03-291-2/+2
| | | | | | | | | | | | | In qproperty_p.h and qpropertyprivate.h there were comments stating this would be used only in certain other headers. Now qproperty_p.h contains functionality to implement bindable properties, so it is used pretty much everywhere in qt. qpropertyprivate.h is only included in qproperty.h. This patch removes the outdated comments. Change-Id: Ie7328691215f875e33e58a13160ce88bf41ca228 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QPropertyBindingPrivate: Support QQmlProperyBindingFabian Kosmale2021-02-151-1/+7
| | | | | | | | | QQmlProperyBinding needs the ability to suspend binding evaluation, and needs access to the propertyDataPtr. Change-Id: If82079ffdf28fb277c6e5083714c28478f6e1729 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QPropertyBindingPrivate: Add further support code for QMLFabian Kosmale2021-02-151-2/+15
| | | | | | | | | | | | | This adds a public function to check whether the QPropertyBindingPrivate is a normal binding, or a QQmlPropertyBinding. In addition, this check is used so that the source location function doesn't return garbage, but instead indicates that the binding was set up from QML. A function to retrieve the binding location from C++ can be added to declarative at a later point. Change-Id: Ica0f70780735fe9c60d01c2b21057d59714079e0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Add method to conditionally remove binding to QObjectCompatPropertyAndreas Buhr2021-02-031-0/+10
| | | | | | | | | Setters of QObjectCompatProperty need to remove the binding, but only if it is not in the wrapper. This patch adds this method to the public interface. Change-Id: Ibc96418fe15b0aeeb2059411ea910ba1f733c255 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove QObjectCompatProperty::operator= for safer usageAndreas Buhr2021-01-291-6/+0
| | | | | | | | | | | | | Introduction of QObjectCompatProperty requires every write to the property to be examined whether it is OK or should be replaced by a setValueBypassingBindings/markDirty combination. The existence of operator= make this difficult as it is easy to miss places where it is written. By not having operator=, we can help developers make sure they had a conscious decision about each write to the property. Change-Id: Ia61ea4722eb0bab26ce7684b85dd03d710cd1751 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProperty: Add private isAnyBindingEvaluating functionFabian Kosmale2021-01-211-0/+4
| | | | | | | | | | | | | | | | | To optimize certain operations, it can be useful to know whether we are currently evaluating a binding. For instance, we have properties whose storage is only alloctaed on-demand when they are set. However, we would also allocate them if they are used in a binding context, as we would otherwise not properly track the dependency. Using isAnyBindingEvaluating in the getter, we can detect this situation, and avoid the allocation if it returns false. This API is private for now, as it exposes some internals of the property system and should be used with care. As it needs to access the TLS variable, it also has a non-negligible cost. Change-Id: I373aabee644fe7020b2ffba7d6a0ad9a1e1b4ec0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Clarify variable names in QPropertyObserverPointer::notifyAndreas Buhr2021-01-111-1/+1
| | | | | | | | | | | | | | In QPropertyObserverPointer::notify and its calling sites, variable names "alreadyKnownToHaveChanged", "knownIfPropertyChanged", "propertyChanged", and at its calling site "knownIfChanged" are used. This is confusing. This patch changes those four to "knownToHaveChanged". For the logic implemented it is not necessary to track whether we have knowledge about having changed and whether it has actually changed (if we have knowledge) separately. Change-Id: I90b86b276ab67b2ed70dba4e456cd90220588870 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove outdated comment and unnecessary initialization callAndreas Buhr2021-01-091-1/+0
| | | | | | | | | | | In construction of QPropertyBindingPrivate was an initialization of inlineDependencyObservers with a comment that this is necessary because of a union. But inlineDependencyObservers is not inside a union. The comment is outdated and the explicit initialization superfluous. This patch removes it. Change-Id: I06544a816533c41af8fc5da3ef44ddd7c18ca86e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add some comments to clarify meaning of observers in property systemAndreas Buhr2020-12-211-3/+3
| | | | | | | | | It took me quite a while to figure out that two objects with a similar type and a similar name which occur side by side have a quite different meaning. Add a comment for the next one. Change-Id: Idf4d63d8ed09ead2c3d82a798e6d7476024209bf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProperty add markdirtyFabian Kosmale2020-12-181-0/+9
| | | | | | | | | | | This adds functionality for marking properties (QProperty and related classes) manually as dirty. This facilliates the integration of bindable properties with non-binable properties and makes it possible for bindable properties to change due to external events. Fixes: QTBUG-89167 Change-Id: I256cf154d914149dacb6cadaba92b13c88c9d027 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Bindable property with initializationIvan Solovev2020-12-171-0/+9
| | | | | | | | | | Implement Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS and Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS macros. They allow to directly initialize the property member. Task-number: QTBUG-85520 Change-Id: I76541d6785bbbf27976b9f0b865fb45be1e9beee Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProperty: Handle eager binding calling setBindingFabian Kosmale2020-12-091-0/+3
| | | | | | | | | | | | | | | | | When an eager binding triggers a setBinding call, we end up with a special kind of binding loop: setBinding() -> evaluate -> notifyObserver ^ | | / ---------------------------- We now catch set condition, and set the binding status to BindingLoop (with a distinct description). Task-number: QTBUG-87153 Task-number: QTBUG-87733 Pick-to: 6.0 Change-Id: I9f9915797d82eab820fc279baceaf89d7e5a3f4a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QPropertyBindingPrivate: Enable QML engine error handlingFabian Kosmale2020-12-081-2/+21
| | | | | | | | | | | | | | | | | The QPropertyBindingSourceLocation is only useful for C++ bindings; for QML bindings we store the binding location in the V4 function. As the QML binding needs to store some additional information for error handling, we allow that memory to be reused by putting it into a union with an array of byte. Moreover, we use some of the space to store a callback pointer, which gets called when an error occurs during binding evaluation. That callback is only called when we know that the binding actually was set up from the QML engine, in which case a bitflag is set. Task-number: QTBUG-87733 Change-Id: I4387a4bd59d4d1ccfe75756ce81f4608319e0490 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QProperty: Avoid spurious dependencies by suspending binding stateFabian Kosmale2020-12-011-6/+16
| | | | | | | | | | Avoid spurious bindings by resetting the binding state before calling the setter of eager properties. Fixes: QTBUG-88999 Pick-to: 6.0 Change-Id: I1e3b5662307d906598335a21d306be9c606529d4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Simplify the safeguarding logic in notify()Lars Knoll2020-11-301-7/+0
| | | | | | | | | | | | | | | | | | The logic in notify() was doing quite a bit more work than it needed to. By inserting a dummy node after the current one instead of replacing it, we can avoid half of the data shuffling that has been happening and also don't need a back pointer when executing the notification. Also avoid calling a semi expensive destructor of QPropertyObserver. Reduces the overhead of notify() by ~30%. Change-Id: I7ce16bcf9cd9c4368c18bf875fc959223452fd4f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit e8ef871e3522f340b4efe32382af7e35ef908665) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Inline the fast path of a few methodsLars Knoll2020-11-301-2/+9
| | | | | | | | | | No need to do function calls for the case where we return immediately after checking a boolean. Change-Id: I3e449850a10fcf82acb843cce6da6dfd98de32ad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit e165f416a752398079590161a18255f9a0058a3e) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove ExtraBit and FlagMask from QPropertyBindingDataLars Knoll2020-11-301-5/+4
| | | | | | | | | | They are not needed and removing it can simplify the code in some places and avoid a couple of masking operations. Change-Id: I0e4241a2784026aa89deed35f408b094e89a11a0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit b1be6e6e6f355bfcb0c3814516f6009c91d2de89) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Inline access to the QBindingStorageLars Knoll2020-11-301-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | And inline the fast checks inside the methods in QBindingStorage. This allows QObjectBindableProperty and friends to inline all the fast checks and almost completely eliminates the overhead for property accesses when no bindings are being used. Read and write times of QObject based properties when no bindings are being used: Read Write Old style property: 3.8ns 7.3ns QObjectBindableProperty (no notification): 4.5ns 4.3ns QObjectBindableProperty (with signal): 4.5ns 7.6ns QObjectBindableProperty (inline accessors): 3.2ns 3.4ns Numbers without this patch: Old style property: 3.8ns 7.9ns QObjectBindableProperty (no notification): 7.2ns 7.7ns QObjectBindableProperty (with signal): 7.2ns 16.0ns QObjectBindableProperty (inline accessors): 6.3ns 6.7ns Change-Id: Ifd1fa3a489c3be8b1468c0b88af547aac397f412 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 98c82fb445acf45cc4c4bc86a5adda43358127bf) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>