aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlbinding_p.h
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Get rid of QQmlBinding::retargetBinding()Lars Knoll2015-04-261-7/+1
| | | | | | | | Instead call setTarget directly and properly resolve the required QQmlPropertyData. Saves some memory for bindings to value types. Change-Id: I542b456685955add7d395764ff85cb3098b3f208 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* CleanupLars Knoll2015-04-261-2/+2
| | | | | | | | Rename QQmlAbstractBinding::object() and propertyIndex() to targetObject() and targetPropertyIndex() Change-Id: Ic50da69e7a7c6412b5abb36f433be046e6566763 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove the manual vtable from QQmlAbstractBindingLars Knoll2015-04-261-17/+8
| | | | | | | | | it's rather hard to maintain, and not really worth it. I believe we can more easily save the one pointer in other places with easier to maintain code. Change-Id: Iaba2d62b82ebe58947fa35b0812b4c70f318007a Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove the QQmlContextData pointer from QQmlBindingLars Knoll2015-04-251-9/+7
| | | | | | | | The pointer is never used in practice, so let's get rid of it and save some memory. Change-Id: I8dccafb4cd3e14397fcf1c30633d60ea7ea9ce0c Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove the manual vtable from QQmlJavaScriptExpressionLars Knoll2015-04-251-2/+2
| | | | | | | | Now that the class got unified with QQmlAbstractExpression, it has a vtable anyway, so we can just as well remove the old hack. Change-Id: Ifa095297e3d75564c4305ce3655eaa57436ef4a8 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of QQmlAbstractExpressionLars Knoll2015-04-241-3/+1
| | | | | | | | | The class is always used together with QQmlJavaScriptExpression, so we can just as well fold the functionality together into one class and simplify our code. Change-Id: I23820e51efaaea16ae5db7e2153a827d7b22999e Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* Get rid of most uses of ValueRefLars Knoll2015-01-231-1/+1
| | | | | | | | | | | | Instead pass a const Value & into the functions With our new inheritance structure, we can get rid of ValueRef and instead simply pass a pointer to a Value again. Pointers to Values are safe to use again now, as they are now guaranteed to be in a place where the GC knows about them. Change-Id: I44c606fde764db3993b8128fd6fb781d3a298e53 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>