aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmljavascriptexpression.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.9' into devSimon Hausmann2017-07-281-2/+2
|\ | | | | | | Change-Id: I7d092cce33cb009d63e7b0df7c71183089dea53f
| * Do not (dis)connectNotify on dynamically created model item objectsErik Verbruggen2017-07-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Refactor le integer types from qjson_p.h to qendian_p.hAllan Sandfeld Jensen2017-07-061-3/+3
|/ | | | | Change-Id: Ibb24b0a55dd94e03fea3104e8af5ddb266004300 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't leak QQmlJavaScriptExpression errorsColin Ogilvie2017-06-161-0/+1
| | | | | | | Ensure any error is deleted when the expression is Change-Id: Ibbfd28f50279d4c66830b40c5c917eb8d98f266e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of QQmlJavaScriptExpression::setFunctionObject()Lars Knoll2016-12-091-12/+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>
* Directly store the referenced QV4::Function pointer in the binding functionLars Knoll2016-12-091-4/+0
| | | | | | | | | There's no need to store a pointer to the original function here, we can simplify the code when storing the pointer to the QV4::Function directly. Change-Id: I377aaecf56a0118606713c26cc7da4da001766b1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't store a source location in the QQmlBindingFunction anymoreLars Knoll2016-12-091-1/+0
| | | | | | | | It's not needed anymore as we now store this in the binding directly. Change-Id: I518c83207f219b690f31200e4d17251075bbd322 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add a setSourceLocation() methodLars Knoll2016-12-091-1/+8
| | | | | Change-Id: I611ab4fe5dd59cb8e07b0fa69ce22c7df5a6c3f2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't create a FunctionObject in createQmlBinding()Lars Knoll2016-12-091-5/+2
| | | | | | | | This also removes the last use of the QmlBindingWrapper, so remove that class as well. Change-Id: I2ec795b6ab695a689fb24d64c9b8809b651c2b37 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Avoid the creation of a FunctionObject for most bindingsLars Knoll2016-12-091-0/+9
| | | | | Change-Id: Ia62d380945250015009d9c2b6ed65f6d830277ef Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't store a FunctionObject in QQmlJavaScriptExpression anymoreLars Knoll2016-12-091-17/+25
| | | | | | | 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-3/+12
| | | | | Change-Id: I070f73f106440667fce2c7fe33310369a6aa1376 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Avoid using the FunctionObject in QQmlJavaScriptExpression::evaluate()Lars Knoll2016-12-091-3/+10
| | | | | | | Rather directly execute the call on the QV4::Function. Change-Id: I1de52075760be6b3a0358af83270ebd4e1d1e8ae Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Mostly use the QV4::Function in javascript expressionsLars Knoll2016-12-091-0/+12
| | | | | | | | | 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/+5
| | | | | | | | And remove it from the derived QQmlBoundSignalExpression class. Change-Id: I93cdc67136ddd916474acd2169faf380e296a900 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Start cleaning up the QmlContextWrapperLars Knoll2016-12-041-2/+2
| | | | | | | | | The class should get merged with the QV4::QmlContext class. Simplify the cleanup by moving both classes into a common file. Change-Id: I0074da79701d5f41eb51681b70fcde85bfd45fc1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML: treat permanent guards more like active guardsv5.8.0-alpha1Erik Verbruggen2016-08-311-2/+8
| | | | | | | Esp. when disabling notifications and marking notifiers as "done". Change-Id: I2d1c3bf048b32f68680744250e4250c3c4d76660 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge dev into 5.8Oswald Buddenhagen2016-08-221-1/+1
|\ | | | | | | Change-Id: If0f273d3d33cec20edda539de6372337c2e4e969
| * Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-08-191-1/+1
| |\ | | | | | | | | | Change-Id: I326616356ee26d4532c6d57558c43c919f0a900d
| | * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-191-1/+1
| | |\ | | | | | | | | | | | | Change-Id: I7bd70996e3372d154c6b0e47336baa22146667b0
| | | * QML: Do not register dependencies of deleted bindingErik Verbruggen2016-08-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Because it can lead to a use-after-free. Change-Id: I6701b370c0ecee4967e5f749f673a6f9ee3d504c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | | Fix exponential signal emission growthStephen Kelly2016-08-151-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 9ab8b9e4 (QML: Do not register static QML dependencies on every call., 2016-04-05) introduced a new concept of separating guards into permanent and active containers. When a property is 'captured' it is added to one or other container. However, while one of the captureProperty overloads added the guards to the correct container, the other overload adds to the wrong container. Presumably this means that a binding can be invoked C+2^N times if the condition for invoking it changes N times. Task-number: QTBUG-55280 Change-Id: I51a31b3dd95825304ba208252289cc5abc744d21 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Fix endian support in compiled data structuresSimon Hausmann2016-07-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal is to make the compiled data structures persistent on disk. In order to make it possible to create these data structures on a "host" system that may have a different endianness than the target system, we now make all the word sized fields little-endian. The template wrappers from QJson provide zero-overhead access for little-endian machines (the vast majority) while maintaining a large degree of source compatibility. Change-Id: I3d30da1fcf3bffb98dbe9337d3a35482fb7b57c8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | QML: Do not register static QML dependencies on every call.Erik Verbruggen2016-06-241-11/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-17/+7
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | V4: allow inlining of ExecutionEngine::{qml,js}Engine()Erik Verbruggen2016-05-201-0/+1
| | | | | | | | | | | | | | | | All other changes are just to be able to include qv8engine_p.h in qv4engine_p.h Change-Id: I71ba2ec42cdc20d5c7d97a74b99b4d1ada1a5ed8 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | QML: make QmlContext::qml{Context,Scope} inlinable.Erik Verbruggen2016-04-051-1/+1
| | | | | | | | | | | | | | | | Both methods are called in QQmlPropertyCapture::registerQmlDependencies, which is called after every binding evaluation. Change-Id: Ic0c7ff96aa7d0be186d103de9d50eae19f42908b Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | QML: allow more methods to get inlined.Erik Verbruggen2016-04-051-8/+0
| | | | | | | | | | | | | | | | 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>
* | V4: Allow some more functions to be inlined.Erik Verbruggen2016-03-311-1/+1
| | | | | | | | | | Change-Id: If9d1f87fd7cf0b12d2827c4574109234be7e8ab8 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* | 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>
* Pass a QmlContext to QV4::Script instead of a contextwrapperLars Knoll2015-09-091-4/+4
| | | | | Change-Id: Ia8db166aacbbe6e8f588179dffa04e2dce9566cb Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move the registerQmlDependencies method into QQmlPropertyCaptureLars Knoll2015-08-201-0/+44
| | | | | | | | 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/+4
| | | | | | | 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-10/+10
| | | | | | | | | 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>
* Don't store the qmlscope object in a persistentLars Knoll2015-06-181-8/+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-5/+6
| | | | | Change-Id: I2ebc0ac8f5085157f5d1ec71a1b75559c6a46f8b Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanup: remove context argument from evaluate methodsLars Knoll2015-04-261-12/+8
| | | | | | | | 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-11/+12
| | | | | | | | 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-1/+35
| | | | | | | | | 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>
* Move exceptionValue and globalObject from the Engine onto the JS stackLars Knoll2015-04-241-1/+1
| | | | | | | | | We'll need to move all GC'ed objects currently stored in ExecutionEngine onto the JS stack for easier management in a new garbage collection scheme. This is the start of that change. Change-Id: Ib3ad8e846875dade8a807ea79f063173d40e4aad Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of qv4value_inl_p.h and replace it by qv4typedvalue_p.hLars Knoll2015-04-241-1/+1
| | | | | | | | This is a cleaner separation and further reduces include dependencies in the definitions of our basic data structured. Change-Id: I18aa86cdea0c0dfbc16075d4d617af97e638811e Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.5' into devLiang Qi2015-04-221-4/+5
|\ | | | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlbinding.cpp src/qml/jsruntime/qv4arraybuffer.cpp src/qml/jsruntime/qv4functionobject.cpp Change-Id: Ic752e9dfd69b282093651c9234c110a49762f06d
| * Speed up binding evaluationSimon Hausmann2015-04-161-4/+5
| | | | | | | | | | | | | | | | | | 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>
* | Get rid of asFunctionObject()Lars Knoll2015-04-211-1/+1
|/ | | | | Change-Id: Ib4858376dc0ec57fa473c80696abc66a570c90ec 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>
* CleanupsLars Knoll2015-01-231-3/+3
| | | | | | | | Remove duplicated methods. Remove some mostly unused methods, and simplify some others. Change-Id: I605b249e54417bb32c3dfc8e22f2c8b6b684a1e1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of most uses of ValueRefLars Knoll2015-01-231-4/+4
| | | | | | | | | | | | 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>
* Make sure we always have an engine when assigning to a PersistentLars Knoll2015-01-131-2/+2
| | | | | | | This prepares things for a rewrite of the internals of Persistent. Change-Id: Ib93ec5911984d1bfce87ffdc3f86bc75f6ecafe9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>