aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlboundsignal.cpp
Commit message (Collapse)AuthorAgeFilesLines
* When binding signals, run the outer function to get the nested oneUlf Hermann2021-08-171-7/+24
| | | | | | | | | | | | | | | The outer function may perform important tasks like setting up a call context with a "this" member for the nested function. In particular, arrow functions retain their original "this" member, no matter where they are executed later. We can detect this condition while generating the compilation unit. If the outer function is not a simple wrapper that only returns the inner function, execute it when binding a signal. Fixes: QTBUG-95659 Pick-to: 6.2 Change-Id: I7dfef2c78378588e6bfc4bedde7889c7f2ce03ef Reviewed-by: Yuya Nishihara <yuya.nishihara@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Finally drop last references to v8Ulf Hermann2021-08-161-1/+1
| | | | | | | | Move files out of the v8 directory and adapt some comments and member names. Change-Id: I36dd9eaf6f51157627327bf46442a54c79a616a5 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Allow property observers on readonly propertiesUlf Hermann2021-06-081-2/+6
| | | | | | | | | This makes it necessary to tolerate evaluate() calls after the engine is gone. With non-QProperty properties this can't happen as the engine controls the observers. Change-Id: Ia700a10ad847b8a174b2346a4ad7a4de7afb0c83 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove pointless evaluate() methodUlf Hermann2021-06-081-24/+1
| | | | | | | | | We never want to evaluate with a QList<QVariant>. The only place where this was called used an empty list. We can just as well use the call with void** then. Change-Id: I9eb93ee37eecec8b01864cc86174d80e5705986c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Optimize invocation of signal handlersUlf Hermann2021-04-011-9/+25
| | | | | | | | | We don't have to do any argument conversion if there are no arguments. Furthermore, we don't need to do the metatype-to-JS conversion if the handler to be invoked is AOT-compiled. Change-Id: I03d8fd7ad07d311d64c39adfd39febbe94396d2f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Clean up JSCallData setupUlf Hermann2021-03-171-3/+3
| | | | | | | | | | | | | | | | | We either have pre-populated arguments and thisObject, then we can just use them and keep them const. Or, we want to allocate and populate the arguments and the thisObject. Then, do allocate them in a separate object, and transform that into JSCallData afterwards if necessary. Furthermore, avoid alloc(0) as that just returns the current stack top. Writing to it will clobber other data. Rather, just use nullptr and crash if it's written to. Also, remove the useless operator-> from JSCallData. That one just confuses the reader. Change-Id: I8310911fcfe005b05a07b78fcb3791d991a0c2ce Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Don't store the scope in JSCallDataUlf Hermann2021-03-171-2/+2
| | | | | | | | | | | We only need it when generating CallData, or when filling in any thisObject or arguments that weren't provided. Provide a constructor that expects thisObject and arguments to be pre-allocated and one that allocates them in a scope passed as argument. Change-Id: Iddfba63f4dbc5b09e2b33fb22a94eea88f515902 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Engine: Cleanup method argument passingFabian Kosmale2021-03-041-3/+3
| | | | | | | | | | | | Instead of arguments around as a pointer to [argc, metaTypeId1, metaTypeId12, ...] pass argc and a pointer to [QMetaType1, QMetaType2] around. Moreover, make use of the fact that we now carry the metatype instead of only the id in a few places, to avoid id -> metatype lookups. Task-number: QTBUG-82931 Change-Id: Ib00e4d793727f85f3358a8162d1aac972daab3d3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML engine internals: Do not require mutable QObject pointerFabian Kosmale2021-02-281-4/+2
| | | | | | | | | | All we need is to get the meta-object from the object. This also works with a const pointer, which is helpful for const-correctness in the FSM framework. Pick-to: 6.1 Change-Id: Ie554fe81e67bced5f74c844c72e7f9b0df7ded58 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QV4::populateJSCallArguments: Use v4->metaTypeToJSFabian Kosmale2021-02-191-1/+1
| | | | | | | | | | It appears that nowadays v4->metaTypeToJS handles QVariant and QObject derived classes just fine, and in exactly the same way as the custom code in populateJSCallArguments did. Task-number: QTBUG-82931 Change-Id: Ic5f97dfc3296a409fdd6a1fcb78d3b9bdba5f3a1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Transform JSCallData args setting into a functionAndrei Golubev2021-02-121-21/+1
| | | | | | Change-Id: I4154a0b5c7115375292794e0564d2f3657e6b4dd Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix QJSValue string parameters used in signalsMaximilian Goldstein2021-02-101-1/+1
| | | | | | | Pick-to: 6.1 6.0 5.15 Fixes: QTBUG-86482 Change-Id: If938fad22f51b08fe3cb20b94634efe46a1eed47 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Adjust to qtbase changesFabian Kosmale2020-09-041-1/+1
| | | | | | | | | | | | | - isQProperty has been renamed to bindable - QNotifiedProperty is no more - Bindable properties have a function to obtain the QBindable; store that information in the qmltypes files. Task-number: QTBUG-86434 Task-number: QTBUG-86435 Change-Id: I2ba593af1e197d04d2c30cfb9e6904a3d2059e4b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Adapt to qtbase changesFabian Kosmale2020-08-231-1/+1
| | | | | | | | | | | The internal QVariant constructor taking a QMetaTypeId has been removed. Thus, construct QMetaTypes where necessary from the id, or avoid a QMetaType -> ID -> QMetaType roundtrip where we already have a metatype. Also fix a few missing includse that were previously transitively included. Change-Id: I56ce92281d616108a4ff80fe5052b919d1282357 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* Replace QQmlBoundSignalExpressionPointer with QQmlRefPointerUlf Hermann2020-06-241-49/+5
| | | | | | | They do the same thing. Change-Id: Ia35832e6175728e7480d09caba6d3833718d9e80 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Update dependencies on 'dev' in qt/qtdeclarativeQt Submodule Update Bot2020-04-071-1/+1
| | | | | Change-Id: Ic09d3ce5f08a3c85d2fa4f0718c34023a7848fd9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for property observersSimon Hausmann2020-04-031-0/+9
| | | | | | | | | Syntactically we call them signal handler expressions :-), now also working when the underlying property doesn't emit an old-style signal but is just a QProperty. Change-Id: I719a3e428f44af0fd48036434aefa682a02f7de1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Encapsulate QQmlContextDataUlf Hermann2020-03-231-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Store a QV4::ReturnedValue in QJSValueUlf Hermann2020-03-181-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Being careful, we can now save primitive values inline. We use the heap pointer of QV4::Value as either QString* or QV4::Value* for complex types. We cannot store persistent managed QV4::Value without the double indirection as those need to be allocated in a special place. The generic QVariant case is not supported anymore. The only place where it was actually needed were the stream operators for QJSValue. Those were fundamentally broken: * A managed QJSValue saved and loaded from a stream was converted to a QVariant-type QJSValue * QVariant-type QJSValues were not callable, could not be objects or arrays, or any of the special types. * Cyclic references were forcibly broken when saving to a data stream. In general the support for saving and loading of managed types to/from a data stream was so abysmally bad that we don't lose much by dropping it. [ChangeLog][QML][Important Behavior Changes] When saving a QJSValue to a QDataStream only primitive values or strings will be retained. Support for objects and arrays was incomplete and unreliable already before. It cannot work correctly as we don't necessarily have a JavaScript heap when loading a QJSValue from a stream. Therefore, we don't have a proper place to keep any managed values. Using QVariant to keep them instead is a bad idea because QVariant cannot represent everything a QJSValue can contain. Fixes: QTBUG-75174 Change-Id: I75697670639bca8d4b1668763d7020c4cf871bda Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add more trace points to Qt QMLMilian Wolff2019-12-131-0/+5
| | | | | | | | | | | | This patch aligns the trace points more with the existing coverage from the Qt QML profiler. The following things can now be traced: - file compilation time - binding execution - signal handling Change-Id: I5b7f1a495f0556482ccd5c07474391b291742ef1 Reviewed-by: Ulf Hermann <ulf.hermann@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>
* Remove QQmlV4HandleUlf Hermann2019-04-101-2/+0
| | | | | | | | This is just an alias for QV4::ReturnedValue. We can as well use the latter. Change-Id: Ibd2c038a3ca726b39a8f0f05e02922adb9fccbdb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML: Split qqmlmetatype{_p.h|.cpp} into multiple filesUlf Hermann2019-02-061-1/+0
| | | | | | | | Having all those classes in one big file promotes spaghetti code and makes the code unreadable. Change-Id: I3b6df93b9cfe1d97228771049b3054e78b868ea3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-2/+2
| | | | | | | | | | | | Get rid of Primitive and move the corresponding methods directly into Value. Mark many methods in Value as constexpr and turn Value into a POD type again. Keep Primitive as a pure alias to Value for source compatibility of other modules that might be using it. Change-Id: Icb47458947dd3482c8852e95782123ea4346f5ec Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix a bunch of test failures for Function.prototype.toString()Lars Knoll2018-08-011-1/+1
| | | | | Change-Id: I36f642e8db7f88698b25eed9e8a64ac2c5896b10 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Simplify signal handler parameter handlingSimon Hausmann2018-07-311-30/+18
| | | | | | | | | | | | | | | | | | | | | | Unify the two QQmlBoundSignalExpression constructors and always call updateInternalClass on the run-time function to set up the parameter name -> argument mapping. This streamlines the code, shares the error handling for unnamed parameter clashes and allows getting rid of the code to extend the formals of functions that become signal handlers in AOT generated cache files. Either onThatSignal: function(param1, param2) { ... } syntax is used and the mapping is fixed and known at AOT/compile time. Or alternatively the dynamic variant is used where the formals are determined at signal handler installation time. Saves a whopping KB of RAM on the QQC1 gallery. Change-Id: I33a9afc06474143d7893f42366cb6553a07ce937 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Simplify handling of function expressions as signal handlersMichael Brasser2018-03-211-0/+12
| | | | | Change-Id: I4bfa05b4619c248119c78d05e64270e6627f6065 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-7/+7
| | | | | | | | | | | | | 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>
* Remove double indirection between QJSEngine and QV4::ExecutionEngineUlf Hermann2018-02-021-8/+10
| | | | | | | | As QJSEngine's handle() method is internal, we can redefine it to return a pointer to an ExecutionEngine. That makes many things easier. Change-Id: Ie3df99e0bad5f00ad4fe73182896cd135fa82994 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Simplify JSCallData constructionLars Knoll2017-11-071-2/+2
| | | | | Change-Id: Ic53532edae9a209aa7125af6f00a9d993d74f1a3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Get rid of the implicit cast operator to a CallDataLars Knoll2017-11-071-2/+2
| | | | | Change-Id: I1c35fbf8f7355bc2393ae931f99e591b800f2f45 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Rename JSCall to JSCallDataLars Knoll2017-11-071-2/+2
| | | | | | | | As, this is going to change in a simple stack based structure to keep pointers to the data to pass to calls. Change-Id: Ia9aa3f81ee3eeba36affd16aac7b2fe97d59aea9 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Always set the correct FunctionObject when calling JS functionsLars Knoll2017-09-021-14/+14
| | | | | | | | | Renamed ScopedCallData to JSCall, enforced passing a JS FunctionObject to it, and added call() and callAsConstructor() methods to it. Change-Id: I30db65c9765c2896b5909fe2105c0934c6dad861 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move ScopedCallData and ScopedStackFrame into a separate fileLars Knoll2017-09-011-0/+1
| | | | | Change-Id: I9ae42aa7a811aa93fe0950725e9d253a0c5e8dba Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Change function signatures for call/construct backLars Knoll2017-08-041-2/+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 Qi2017-01-261-1/+1
|\ | | | | | | | | | | | | | | Conflicts: src/quick/util/qquickutilmodule.cpp tools/qmllint/main.cpp Change-Id: Ic2283f88c293ca7fc776de3e83eb4c7812309d8a
| * Fix support for QJSValue as C++ signal parameter type, part 2Simon Hausmann2017-01-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After commit 0e3380f9c6ab6e3ea7398caccf5aa84f1575f1cd we wouldn't crash anymore, if QJSValue::UndefinedValue was provided as value for a QJSValue C++ signal parameter. However that was not a complete fix for the regression of commit aa869cbb06bcf005e238059a2cb0205947ff0b5f, as other primitive values stored in QJSValue as QVariant were not converted, so for example QJSValue(42). So let's fix this once and for all by using QJSValuePrivate::valueForData, that handles all types of QJSValuePrivate encodings. Task-number: QTBUG-58133 Change-Id: Ib7c0461b18df6260ccd4bce729ae2348281eb7f3 Reviewed-by: Arnaud Vrac <avrac@freebox.fr> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2017-01-141-1/+4
|\| | | | | | | | | | | | | Conflicts: .qmake.conf Change-Id: I9d87ed86e95b5901a86cc3aa65d7ac39b0b708c2
| * Fix crash when C++ QJSValue parameterized signal interacts with JSSimon Hausmann2017-01-131-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | When converting the parameters of a C++ signal to JS values to provide to a signal handler written in JS, the conversion of a QJSValue to a QV4::Value* may yield a null pointer in case of a default constructed QJSValue for example. This is a regression from commit aa869cbb06bcf005e238059a2cb0205947ff0b5f and we must check for this. Task-number: QTBUG-58133 Change-Id: I528b606b2851dfb3072e54902bd8843d31571a55 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Port existing qmlInfo callers to qmlWarningRobin Burchell2017-01-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Now that qmlInfo actually reports info messages, we want to change existing callers to use warning-level messages to preserve the original message level. This was done through: perl -p -i -e "s/qmlInfo\(/qmlWarning\(/" **/*.{cpp,h,qdoc} .. with a little care taken to only add the hunks that should be changed. Change-Id: I511cee11ce0a26ec1048cd2b84c7536b812a0d89 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-12-141-44/+24
|\| | | | | | | | | | | | | | | | | | | | | | | 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/+2
| | | | | | | | | | | | | | | | 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>
| * Pass a QV4::Function to the QQmlBoundSignalExpression constructorLars Knoll2016-12-091-3/+4
| | | | | | | | | | | | | | And avoid the creation of a temporary FunctionObject Change-Id: Idaacfd978ac4ee26960bdf185272cc44d6618a71 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Get rid of FunctionObject::createQmlFunctionLars Knoll2016-12-091-6/+14
| | | | | | | | | | | | | | | | Instead, simply create a QmlContext, and setup the bindings with the QV4::Function itself. Change-Id: I9db93b15112e43a6d5e275d126fb20f9c8833e8f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Limit access to m_function to QQmlJavaScriptExpressionLars Knoll2016-12-091-3/+7
| | | | | | | | | | Change-Id: I070f73f106440667fce2c7fe33310369a6aa1376 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Don't create a QML function is the signal parameters are invalidLars Knoll2016-12-091-3/+1
| | | | | | | | | | | | | | Moves the error checking to where the error occurs. Change-Id: I2590d3a9d41f41c16d19e4f5883b78a8b28a883c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Remove some dead codeLars Knoll2016-12-091-4/+0
| | | | | | | | | | Change-Id: Ibf6d50926edd85ebee545bcfdfcd14cb0eeab969 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Mostly use the QV4::Function in javascript expressionsLars Knoll2016-12-091-17/+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-13/+0
| | | | | | | | | | | | | | | | 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>