aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlbinding_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Update commercial license headers"Tarja Sundqvist2022-11-241-22/+22
| | | | | | | | | | | This reverts commit 74089697cf2a4961fb697100555b17ae2342d734. Revert of commercial license headers is required for the Qt 6.2.x opensource releases, Qt 6.2.5 onwards. Task-number: QTBUG-107760 Change-Id: Id49069cb5e5f261da185fd082dfb71deb259d387 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Update commercial license headersTarja Sundqvist2022-06-041-22/+22
| | | | | | | | | | | | | | | Updated header.COMM to the files in tqtc-qtdeclarative. Examples, tests, or documentation files are not updated. The commercial license header may contain some additional lines so that its line count equals with the earlier license header. Reason for this is that some autotests use hard coded line numbers and a change in the line count causes failures in tests. Task-number: QTQAINFRA-4941 Change-Id: I32f554b0a8cb527f74d46f3c02b0e745d9fc5ddf Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlBinding::dependencies: Handle QPropertyFabian Kosmale2021-10-011-0/+1
| | | | | | | | | | | | | | The method did not consider QProperty properties, as those do not show up via the active guards mechanism. At some point, we probably also want to introduce QQmlAnyBinding::dependencies, as there are now bindings which do not derive from QQmlBinding. Change-Id: Ib4b227a440e9494c09d92028f9eaa5ad1e87342f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit de28bc00f514c3ee8d8fd3166973c063766e77fd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Skip superfluous property capture attemptFabian Kosmale2021-08-091-0/+2
| | | | | | | | | | | If a QQmlProperyBinding tries to capture a QProperty, there is nothing to do as the dependency tracking happens in C++ anyway. Thus we can avoid calling captureProperty. Change-Id: I96b2876d4b2ba10b00af8342be9beae660a95ef3 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 3cf2df4a7e8a53a63068613311c4799e55c971b9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QQmlBinding: provide setTarget overload without QQmlPropertyDataAndrei Golubev2021-06-071-0/+1
| | | | | | | | | | | | | Similarly to create(), setTarget() also accepts QQmlPropertyData which is a bit too much for the object creation compiler case. Providing minimalistic API instead allows not to construct QQmlPropertyData when QMetaProperty is available Related to 06893b68c6b1f70cb7ff255db1fa9d14697403fa. Change-Id: I9a54dbdf6b7cddeeda995558a2539254c26a9c6d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Support binding creation from QMetaType of propertyAndrei Golubev2021-06-031-0/+5
| | | | | | | | | | | | | | QQmlBinding/QQmlPropertyBinding, created from QQmlPropertyData, really only needed QMetaType (which is ideally always in sync with custom data in QQmlPropertyData), so provide the versions that accept QMetaType This way we don't need to care about QQmlPropertyData at all when we know QMetaProperty, which is, for example, the case of object creation compiler Change-Id: Ia7794e5575b71ffaf111dd35b352da36598c631f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Optimize QQmlBinding::slowWrite()Ulf Hermann2021-04-221-0/+4
| | | | | | | | | | | That's not uncommon at all, and we don't need to convert the value back and forth for it. If we have a metatype/void* representation already, we can just create a QVariant from that and forward it to writeValueProperty(). Even the QVariant is unnecessary, but that will be resolved in a second step. Change-Id: Ideae979a73276c9fba1bc19c10d799b8fe59dde5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Provide an AOT-optimized code path for binding evaluationUlf Hermann2021-03-291-0/+5
| | | | | | | | | We don't need to convert the results of calling binding functions back and forth. Change-Id: Icb997532ebc3092f3e3882a804173346b450e435 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace QFlagPointer with QTaggedPointerSimon Hausmann2020-04-031-4/+4
| | | | | | | | The latter has the advantage of allowing the use of a real type for the tag, instead of the generic flag/flag2 boolean accessors. Change-Id: Icc9e854ce4af3eb5808a4bed45aa22f377e223da Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Minor cleanupSimon Hausmann2020-03-301-2/+0
| | | | | | | Remove unnecessary shadowing of function from base class. Change-Id: I46539be359ae794e357930ac6f2287f5d14331d6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Minor cleanup in QQmlJavaScriptExpressionSimon Hausmann2020-03-231-1/+0
| | | | | | | | | | We _can_ provide a default implementation for expressionIdentifier() - it doesn't have to be located in QQmlBinding as it only uses fields from QQmlJavaScriptExpression. Change-Id: Ifcead72c4f3ed4597cde732afca466eba83f5e0d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Encapsulate QQmlContextDataUlf Hermann2020-03-231-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This class is not a private detail of QQmlContext. And it is incredibly hard to see who owns what in there. Let's add some civilization ... We enforce refcounting for QQmlContextData across the code base, with two exceptions: 1. QQmlContextPrivate may or may not own its QQmlContextData. 2. We may request a QQmlContextData owned by its parent QQmlContextData. For these two cases we keep flags in QQmlContextData and when the respective field (m_parent or m_publicContext) is reset, we release() once. Furthermore, QQmlContextData and QQmlGuardedContextData are moved to their own files, in order to de-spaghettify qqmlcontext_p.h and qqmlcontext.cpp. When the QQmlEngine is deleted, any QQmlComponents drop their object creators now, in order to release any context data held by those. Before, the context data would be deleted, but the object creators would retain the dangling pointer. [ChangeLog][QML][Important Behavior Changes] QQmlContext::baseUrl() does what the documentation says now: It prefers explicitly set baseUrls over compilation unit URLs. Only if no baseUrl is set, the CU's URL is returned. It used to prefer the CU's URL. Change-Id: Ieeb5dcb07b45d891526191321386d5443b8f5738 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Split qqmltypeloader{_p.h|.cpp} into a several filesUlf Hermann2019-07-111-0/+1
| | | | | | | No one can read this mess. Change-Id: Icec4f2afc466435c1ae5e4e80fa2c1b5baf7d087 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split CompiledData::CompilationUnit in twoUlf Hermann2019-05-161-1/+1
| | | | | | | | We need a CompilationUnit that only holds the data needed for compilation and another one that is executable by the runtime. Change-Id: I704d859ba028576a18460f5e3a59f210f64535d3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove bindings that have no dependenciesSimon Hausmann2018-05-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After the initial enabling of a binding we can quickly determine if there is a chance whether this binding will be re-evaluated again in the future as a consequence of dependency changes (properties or translations). If that is not the case, then we can save memory by removing that binding again. One implementation consequence of this change is that such constant bindings used with the "when" property of states require a proper reference count increase, which was previously implicit through the binding association with the target object. In tst_qqmlecmascript a test that verifies that we don't create run-time bindings for assignments of literal "null" to QObject pointer properties now also covers the more complex case where we don't know the property at parse time. We still evaluate the binding once though and perform one property assignment. Similarly on the QtQuick Designer Support API test side a binding such as x: Math.max(0, 200) will not create a persistent binding anymore and needs a tweak to remain. On a large scale application this optimization saved up to 5% of all bindings on start-up (~9000 of ~180000). On Linux x86-64 one binding is approximately 144 bytes, so the savings are in the range of ~1.2 MB of heap, as well as reduced fragmentation. Task-number: QTBUG-64541 Change-Id: Id3653008346fdf36611f5b4c4e82f5f78b5319aa Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up manual reference of QQmlTypeData and QQmlPropertyCacheSimon Hausmann2018-04-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | We have a few places in the type loader where we do adventurous manual reference counting, where getType() returns a raw pointer that has been addref()'ed and then sometimes somehow we call release() later. Commit 0b394e30bba4f6bb7e6f7dbe5585a2e15aa0f21d is an example of where this can easily go wrong. As a consequence and also in preparation for future work on the type loader, this patch starts replacing the manual reference counting there. Changing the return type from QQmlTypeData *getType() to a QQmlRefPointer<> itself is not sufficient though, as the implicit operator T*() will still allow the caller to store the result as a raw pointer. Therefore this patch removes the "unsafe" implicit extraction operator. As a result of that change, other types that are sometimes stored in QQmlRefPointer are also affected and their usage needs to be adapted to QQmlRefPointer usage or manual raw pointer extraction with .data(). Change-Id: I18fd40634047f13196a237f4e6766cbef3bfbea2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix calling Qt.binding() on bound functionsLars Knoll2018-04-161-0/+11
| | | | | | | | | | | | | | | | | | | Calling Qt.binding() on a bound function object is a valid use case and used to work until Qt 5.8. The problem was that we optimized the code in QQmlBinding and QQmlJavascriptExpression to directly work on a QV4::Function, so this wouldn't work anymore. To fix this make sure recursive calls to Function.bind() are unrolled (so that the BoundFunction's target is never a bound function itself), then add the bound function as an optional member to the QQmlBinding and use it's bound arguments if present. Task-number: QTBUG-61927 Change-Id: I472214ddd82fc2a1212efd9b769861fc43d2ddaf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix issue with bindings to aliases that cannot yet be resolvedErik Verbruggen2018-03-091-1/+3
| | | | | | | | | | | | | | When an alias points to a child object which has not yet been initialized, it's id won't have been registered yet, so setting up a binding to it will result in a crash. The fix is: when setting a binding target fails, and its target property is an alias, queue them until all bindings have been set up, and try again. Task-number: QTBUG-57041 Change-Id: I4dc5a6d25c0a32fed9fd952c955e2006c76be45a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* use the override keyword consistently and correctly (clang-tidy)Shawn Rutledge2018-02-271-1/+1
| | | | | Change-Id: If9e28d143f8cba3df3c757476b4f2265e2eb8b2a Reviewed-by: Johan Helsing <johan.helsing@qt.io>
* Replace Q_DECL_OVERRIDE with overrideKevin Funk2017-09-251-3/+3
| | | | | Change-Id: I176f91a8c51e81a2df3fe91733118261491223ee Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add API to learn about QQmlBinding's dependenciesAnton Kreuzkamp2017-08-131-0/+9
| | | | | | | | | | | Adds a method `dependencies()` to QQmlBinding, that returns a QVector<QQmlProperty> of all properties the binding depends on. The API is meant to be used in debugging tools (e.g. in GammaRay). Also adds a public method subBindings() to QQmlValueTypeProxyBinding in order to be able to access their dependencies. Change-Id: Ib833703ec9e632661626c4532b8d73997f38e62b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for QEvent::LanguageChangeSimon Hausmann2017-07-141-0/+2
| | | | | | | | | | | | | | | | | | | Respond to the language change event by refreshing all binding expressions. For constant string translation bindings we must now create special QQmlBinding instances instead of a one-time property write meta-call upon instantiation. Those however are more lightweight than an entire JavaScript expression. In addition this provides a slot to explicitly trigger a re-evaluation of bindings, to make it a little easier to discover for the developer. [ChangeLog][QtQml][QQmlEngine] Added retranslate() slot and QEvent::LanguageChange support to refresh bindings when changing the language at run-time. Task-number: QTBUG-15602 Change-Id: Ide174648e1d8a5738acb88e15495018d0869d7bc Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-12-141-6/+4
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp src/qml/qml/qqmlimport.cpp src/quick/items/context2d/qquickcontext2dtexture_p.h tools/qmleasing/splineeditor.h Change-Id: I8f6630fcac243824350986c8e9f4bd6483bf20b5
| * Avoid passing a FunctionObject to QQmlBinding::create()Lars Knoll2016-12-091-2/+1
| | | | | | | | | | | | | | | | Like this we can remove the QQmlBinding::create() overload that takes a FunctionObject. Change-Id: Ib6c37395ded325e68cf0fbf3afd08fb6dd6efa3b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Avoid the creation of a FunctionObject for most bindingsLars Knoll2016-12-091-0/+2
| | | | | | | | | | Change-Id: Ia62d380945250015009d9c2b6ed65f6d830277ef Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Change signature of QQmlBinding::create to take a FunctionObject *Lars Knoll2016-12-091-1/+1
| | | | | | | | | | | | | | This is what's in the Value in all cases anyway. Change-Id: I212c4c4076050e8d0ea4cf6f72a1683e132cd51b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Remove unused argumentLars Knoll2016-12-091-2/+1
| | | | | | | | | | Change-Id: Ie490f113b6fc48ea75eb5903a79dddb02faa7301 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Cleanup and reduce the number of overloads for QQmlBinding::create()Lars Knoll2016-12-061-3/+1
| | | | | | | | | | Change-Id: Ibcd277bc434638e5c6e8e9ccea634aa25cde1643 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Qml, Imports: mark some methods as constAnton Kudryavtsev2016-10-131-2/+2
|/ | | | | | | These methods do not modify objects. Change-Id: I67b1a10cfd0b32688500fca3265a96f53afd1b57 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Minor binding code cleanupSimon Hausmann2016-08-181-1/+1
| | | | | | | | Remove the QQmlBinding *binding argument as it is always the this pointer. Change-Id: I76ccf64a1d37ce32089c81f60466dce79b9fa5bf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QML: Split off value type information from property dataErik Verbruggen2016-08-091-4/+4
| | | | | Change-Id: I2ae2fb0f18af9b866cc9482fd4f42d9d4269f8cb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML: Introduce QQmlPropertyIndexErik Verbruggen2016-08-041-1/+0
| | | | | | | | This helps in making it clear when an index is a plain old number and when it consists of an encoded value type index. Change-Id: Ic50d95caf244ed0ee2d62bdba53910a371cfee04 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML: Add specialized binding for QObject* propertiesErik Verbruggen2016-08-021-1/+1
| | | | | | | | In it we can cache the meta-type for the specific QObject subclass of the property type. This reduces the number of calls to QMetaType. Change-Id: Ie3774395c971bc33af58a8290453b19631939ea8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML: Unify property reads/writes and use accessorsErik Verbruggen2016-07-251-4/+4
| | | | | | | | | Pass property reads/writes through utility functions in QQmlProperty, which in turn will try to use accessors when available (and no interceptors have to be called). Change-Id: I60ecfc202b6024bfe4a33206a46299787b152546 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML: Introduce write accessors to QQmlAccessorsErik Verbruggen2016-07-081-3/+1
| | | | | | | | | | | | | | | | Same idea as the read accessors, but with a slight difference: the property setters do emit signals, so we can't do a direct property write and have to call the setter. However, it does circumvent the meta-calls. There is one gotcha: if a property is intercepted (e.g. by a Behavior), we still have to do the meta-call in order to dispatch the write to the interceptor. According to valgrind, this saves 138 instructions on x86 for every "accessible" property write. Change-Id: I07dbac95613415559ffa1691734a5af7c84721fc Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML: Specialize bindings based on target property type.Erik Verbruggen2016-06-271-11/+21
| | | | | | | | | | | When we can determine the type of a target property during type compilation, we can skip a whole bunch of code that deals with converting the result of a binding to the correct (target) type. This removes 65 instructions on x86 for such typed bindings. Change-Id: Id2c7c57b9ae6dfbeb921121beae9630604ca1d17 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove unused QPointerValuePair templateFrank Meerkoetter2016-04-181-1/+0
| | | | | | Change-Id: I93bc5951d555f799bb956020433d3087504e8f9f Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Mark overridden virtuals as suchFrank Meerkoetter2016-03-151-7/+5
| | | | | Change-Id: Ifcfbd9810bc342ceaaa74f3b31c16001485516f6 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-191-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Remove a global read-write QQmlBinding::Invalid variableLars Knoll2015-06-101-1/+3
| | | | | Change-Id: I3ca148ae021ffc349b943231cc749828b0b7816c Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Make bindings refcountedLars Knoll2015-06-101-4/+2
| | | | | | | | | | | Refcounting our bindings greatly simplifies our memory management of the objects and ensures we safely clean them all up. In addition, it allows us to remove the m_mePtr and weak reference handling from QQmlAbstractBinding as we can safely handle this through the same mechanism. Change-Id: If23ebc8be276096146952b0008b62018f5d57faf Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move the writeBinding method into QQmlBindingLars Knoll2015-06-051-0/+5
| | | | | | | | It's only called from there; this simplifies the code and will allow some further optimizations. Change-Id: I1f0befe620beaa0bbf961fc829881ef7b5c2e435 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move the target property index into the common base classLars Knoll2015-06-051-3/+0
| | | | | | | | This unifies some more code between the different binding classes Change-Id: I891dc9358cf9598a0c1e21df8a62d6f8a4193985 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move the target object into the base classLars Knoll2015-06-051-2/+0
| | | | | Change-Id: I912d7665b49c8e9b2d38e78bfcfc4b3d39ca7459 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove the QQmlPropertyData from the bindingLars Knoll2015-06-051-6/+7
| | | | | | | Simply store the encoded property index instead. Change-Id: I235030c3d658df3e5df6efafc9c5b2c22200e0a8 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Save one more pointer for every bindingLars Knoll2015-04-271-7/+5
| | | | | Change-Id: I434fda86b8e06484548be416f92a3cde9df6b906 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of QQmlBinding::property()Lars Knoll2015-04-271-1/+0
| | | | | | | The method is slow and not required anymore Change-Id: I8c2bc6eeedbd15b901b60aa08408fe8c32a81707 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move m_function into the base classLars Knoll2015-04-271-2/+0
| | | | | Change-Id: I2ebc0ac8f5085157f5d1ec71a1b75559c6a46f8b Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Rename the v4function member variablesLars Knoll2015-04-271-1/+1
| | | | | | | | | Name the functions consistently between all classes inheriting from QQmlJavascriptExpression to prepare the move of the member into the base class. Change-Id: I161e829e3921816e675b73b6c1f3ca06315b328f Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Make update() non virtualLars Knoll2015-04-271-1/+1
| | | | | | | It's only ever called on QQmlBinding objects. Change-Id: I50dd2996db9644e0df14ec930de17a7e621a0f47 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>