aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmljavascriptexpression_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Split CompiledData::CompilationUnit in twoUlf Hermann2019-05-161-2/+2
| | | | | | | | 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>
* Move model types into their own libraryUlf Hermann2019-05-021-1/+1
| | | | | | | | | | The model types are not part of the core QML runtime and should only be loaded if you explicitly import them. We cannot enforce that in Qt5 as some of them are available from the QtQml import, but we can change it in Qt6. Change-Id: I1e49e84d748e352537ec2d4af901c034c91d038f Reviewed-by: Erik Verbruggen <erik.verbruggen@me.com>
* Remove dead compile time QML context/scope property and id object codeSimon Hausmann2019-03-201-19/+2
| | | | | | | | | | | After enabling lookups in QML files, we can remove all the code that tries to deal with (type) compile time detection of access to id objects and properties of the scope/context object. This also allows removing quite a bit of run-time code paths and even byte code instructions. Task-number: QTBUG-69898 Change-Id: I7b26d7983393594a3ef56466d3e633f1822b76f4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove bindings that have no dependenciesSimon Hausmann2018-05-161-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-3/+1
| | | | | | | | | | | | | | | | | | | 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 crash when QML engine warning handler feeds errors back into QMLSimon Hausmann2018-04-091-7/+9
| | | | | | | | | | | | | | When a QQmlEngine warning handler that's called during component instantiation results in subsequent component instantiations, either via the signal or via a Qt message handler like in the bug report, then we might end up modifying the linked list of errored bindings before returning from the QQmlEnginePrivate::warning() call. The easy fix is to extract the QQmlError, unlink the delayed error from the linked list and then deliver the error to the QQmlEngine. Change-Id: I6b7be61b57b35636282595937046ff76091144a3 Task-number: QTBUG-53293 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-11/+11
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/dev' into wip/new-backendLars Knoll2017-08-221-8/+10
|\ | | | | | | Change-Id: Iff06429f948ac6cdec77a9e5bb8c5375c56fe705
| * Add API to learn about QQmlBinding's dependenciesAnton Kreuzkamp2017-08-131-7/+7
| | | | | | | | | | | | | | | | | | | | | | 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>
| * Merge remote-tracking branch 'origin/5.9' into devSimon Hausmann2017-07-281-1/+1
| |\ | | | | | | | | | Change-Id: I7d092cce33cb009d63e7b0df7c71183089dea53f
| | * Do not (dis)connectNotify on dynamically created model item objectsErik Verbruggen2017-07-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These item objects are direct subclasses of QObject, and cannot override connectNotify/disconnectNotify. This prevents the creation of the backing QMetaObject during disconnect, which happens during destruction, which in turn will call back into the model that is being destroyed. Task-number: QTBUG-59704 Change-Id: I7f997e5d2fda242b38e67b9147224d72aa4508ba 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>
* | Get rid of simpleCallLars Knoll2017-08-101-1/+1
| | | | | | | | | | | | | | | | After the recent changes this can easily be unified with the call method without loss of performance. Change-Id: I0385b47b6a86e890f97dcbada3a1be1129ae0b84 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Refactor context handlingLars Knoll2017-08-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the push/pop context instructions to not modify the JS stack anymore, as that can cause conflicts with the VME (and was an ugly hack in any case). Instead, these instructions not return the old context, that is then stored in a temporary. Get rid of Engine::current and Engine::currentContext. The StackFrame structures do now contain the only and authoritive data. This finally gives us a nice setup where we create and destroy frames on the stack when entering/leaving functions. Change-Id: If161e3e941f59865c47ecfe1e094faf62b52bfa0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Remove Scope dependency from registerQmlDependenciesLars Knoll2017-08-081-1/+1
| | | | | | | | | | | | | | An engine pointer is sufficient. Change-Id: I6430cfeac3bd2881e89bbbd22ff31ffbd2a2339a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Change function signatures for call/construct backLars Knoll2017-08-041-1/+2
|/ | | | | | | | Change those back again to return a value. This will be required to avoid creation of Scope objects between JS function calls. Change-Id: I05cb5cf8fd0c13dcefa60d213ccd5983fab57ea3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-12-141-2/+11
|\ | | | | | | | | | | | | | | | | | | | | | | 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
| * Get rid of QQmlJavaScriptExpression::setFunctionObject()Lars Knoll2016-12-091-1/+0
| | | | | | | | | | | | | | | | It was only used in one place now, and the code is actually cleaner when calling setupFunction() instead. Change-Id: Idfe2842b81e765569f2c70f3d5dcd1862442a2ee Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Avoid passing a FunctionObject to QQmlBinding::create()Lars Knoll2016-12-091-1/+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>
| * Add a setSourceLocation() methodLars Knoll2016-12-091-0/+1
| | | | | | | | | | Change-Id: I611ab4fe5dd59cb8e07b0fa69ce22c7df5a6c3f2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Avoid the creation of a FunctionObject for most bindingsLars Knoll2016-12-091-0/+1
| | | | | | | | | | Change-Id: Ia62d380945250015009d9c2b6ed65f6d830277ef Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Don't store a FunctionObject in QQmlJavaScriptExpression anymoreLars Knoll2016-12-091-1/+4
| | | | | | | | | | | | | | Instead store the QmlContext, the QV4::Function and a source location. Change-Id: Iafa54c09b9be7e78bace3498673ca94a2a145c97 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Limit access to m_function to QQmlJavaScriptExpressionLars Knoll2016-12-091-1/+2
| | | | | | | | | | Change-Id: I070f73f106440667fce2c7fe33310369a6aa1376 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Mostly use the QV4::Function in javascript expressionsLars Knoll2016-12-091-0/+2
| | | | | | | | | | | | | | | | | | Move the function() accessor from QQmlBoundSIgnal to QQmlJavaScriptExpression. Change the profiler to operate on QV4::Function objects for binding profiling. Change-Id: Ic7ce83c487ceb69cad4b16e3dab42026238b7e82 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Add sourceLocation() accessor to QQmlJavascriptExpressionLars Knoll2016-12-091-0/+2
| | | | | | | | | | | | | | | | And remove it from the derived QQmlBoundSignalExpression class. Change-Id: I93cdc67136ddd916474acd2169faf380e296a900 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Qml, Imports: mark some methods as constAnton Kudryavtsev2016-10-131-1/+1
|/ | | | | | | These methods do not modify objects. Change-Id: I67b1a10cfd0b32688500fca3265a96f53afd1b57 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: treat permanent guards more like active guardsv5.8.0-alpha1Erik Verbruggen2016-08-311-0/+8
| | | | | | | Esp. when disabling notifications and marking notifiers as "done". Change-Id: I2d1c3bf048b32f68680744250e4250c3c4d76660 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML: Do not register static QML dependencies on every call.Erik Verbruggen2016-06-241-3/+10
| | | | | | | | | | | | | | | | | | | | | | QML objects can be re-parented on the fly, resulting in different dependencies for expressions like 'parent.width'. So, because of this, dependencies are cleared and re-calculated after every binding evaluation. However, dependencies on properties of the scope and context objects cannot change, because these objects do not get changed for the life-time of a binding. So we can permanently register them. This is only done for bindings, not for functions, because those might be conditionally executed. According to valgrind, this is a reduction of ~186 instructions on x86 for every evaluation of: Item { height: width } Change-Id: Ib095497323d4f08caf712d480007e2627a176369 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* V4: Pass scope around as parameters inside the runtime.Erik Verbruggen2016-06-221-3/+2
| | | | | | | | | | | | | | | | The implementation of many (or all) runtime functions consist of first creating a QV4::Scope, which saves and restores the JS stack pointer. It also prevents tail-calls because of that restoring behavior. In many cases it suffices to do that at the entry-point of the runtime. The return value of a JS function call is now also stored in the scope. Previously, all return values were stored in a ScopedValue, got loaded on return, and immediately stored in another ScopedValue in the caller. This resulted in a lot of stores, where now there is only one store needed, and no extra ScopedValue for every function. Change-Id: I13d80fc0ce72c5702ef1536d41d12f710c5914fa 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>
* QML: allow more methods to get inlined.Erik Verbruggen2016-04-051-0/+7
| | | | | | | | Most of these methods are small, and all of them lie in the 'hot path' for simple bindings like 'width: parent.width'. Change-Id: I0071cec92b49437a352160b0283ed6c89a278a07 Reviewed-by: Lars Knoll <lars.knoll@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>
* Move the registerQmlDependencies method into QQmlPropertyCaptureLars Knoll2015-08-201-0/+2
| | | | | | | | This is where the method logically belongs, and removes one more thing from the context wrapper. Change-Id: Ibc076c9b31903a484ad4517402eca2a3b7f0d660 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Smaller cleanup to QQmlJavaScriptExpressionLars Knoll2015-06-181-4/+2
| | | | | | | Clean up some of the code to create binding expressions. Change-Id: I1cd826685713b44166c58b114fa91135a664591d Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Simplify property capturing codeLars Knoll2015-06-181-21/+23
| | | | | | | | | No need to inherit from a base class defined in QQmlEnginePrivate. The capture handling can be a simple value based class without virtual methods that is allocated on the stack. Change-Id: Ib0ddf4afcaf154b3f953d8c9322f5bec196d7abf Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move setting the callback type for the endpoint to the constructorLars Knoll2015-06-181-2/+2
| | | | | Change-Id: I1881fc3e79f93e3cfe01a201d60956c460c0d196 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Don't store the qmlscope object in a persistentLars Knoll2015-06-181-4/+2
| | | | | | | | | | This doesn't make sense, as the persistent is never being used. So either the scope object is being used from somewhere else in which case it'll be referenced and marked from there, or it's not being used in which case, we might as well collect it. Change-Id: I56cb45282cbc795d4c59314c10491dedb9b7d478 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move m_function into the base classLars Knoll2015-04-271-2/+4
| | | | | Change-Id: I2ebc0ac8f5085157f5d1ec71a1b75559c6a46f8b Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanup: remove context argument from evaluate methodsLars Knoll2015-04-261-2/+2
| | | | | | | | We always called evaluate with our own context, so there's no need to pass it along as an argument. Change-Id: I3463165eb2947b230c7acf54e7c29dd5d3b8e17c Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove the manual vtable from QQmlJavaScriptExpressionLars Knoll2015-04-251-14/+7
| | | | | | | | 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/+15
| | | | | | | | | 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>
* Fix forward declaration of QQmlSourceLocation.Friedemann Kleint2015-04-171-1/+1
| | | | | | | | Fix warning: qtdeclarative/src/qml/qml/qqmljavascriptexpression_p.h(55) : warning C4099: 'QQmlSourceLocation' : type name first seen using 'struct' now seen using 'class' Change-Id: Id441502913180631fe09c2f256498063c8f144b1 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Speed up binding evaluationSimon Hausmann2015-04-161-1/+3
| | | | | | | | | Don't spend any cycles of determining the location of the binding (file, line, column) unless we really need that information. That's the case when the profiler is active or an error happens. Change-Id: Iae97808d500b88fed6a813e8b224aa6ebe04d3b6 Reviewed-by: Lars Knoll <lars.knoll@digia.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-2/+2
| | | | | | | | | | | | 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>
* Remove the executioncontext in a few more places where it's not neededLars Knoll2014-11-211-5/+1
| | | | | Change-Id: I4c92c7bc9d94d8265e306f45d863fdc080a5e2a6 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* Fix crash when the currently running binding is deleted.Michael Brasser2014-02-151-2/+3
| | | | | | | | | | | | | | | | | | | | Stop capturing properties once the expression is deleted. The following example triggers invalid read/write memcheck errors when trying to capture propFromParentScope: Item { property real testProp: { if (x == 0) testProp = 7 return propFromParentScope } } Which can eventually lead to a crash. Task-number: QTBUG-36798 Change-Id: I233de2c81498884df0563e8ce155752845aafcfb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Ensure the this object is set correctly to the scope object in binding ↵Simon Hausmann2013-11-051-13/+0
| | | | | | | | | expressions This is a regression from 5.1 Change-Id: I61ad372a02d937c195dad74bd9fcb8fd4410d97a Reviewed-by: Lars Knoll <lars.knoll@digia.com>