aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlobjectcreator_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Speed up property binding initialization on object creationSimon Hausmann2015-04-211-4/+5
| | | | | | | | | | Avoid repeated string hashing and lookups in the property cache in order to retrieve the property details when initializing literal and script bindings. Instead we now cache the property data at type validation time, similar to how the property data was encoded in the VME instructions in the old engine. Change-Id: I3957c7c4c3e26dfa97c4880b23940a3755ee90e4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Speed up creation of objects without script bindingsSimon Hausmann2015-04-161-1/+4
| | | | | | | | Avoid the creation of the QML binding wrappers if we don't need it, by moving the creation into a function that creates it on demand. Change-Id: I1af6a8507a114c1a0b83374704981b7ed4c4a3fc 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>
* Merge remote-tracking branch 'origin/5.3' into 5.4Simon Hausmann2014-08-261-4/+8
|\ | | | | | | | | | | Conflicts: src/qml/qml/qqmlobjectcreator_p.h Change-Id: I60858ddb46866a8fa1a8576bb05b412afeeb4e41
| * Fix crash with early QObject property accessSimon Hausmann2014-08-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the reported bug, it can happen that we try to access the compile-time resolved QObject property of an object that is referenced by id. The binding that uses this is triggered when the property changes but _also_ when the id referenced object gets either created or deleted. The first time the binding is evaluated is very early on, when the id referenced object is not created yet, so the binding evaluation fails. However the dependency is set up, and so later then the id referenced object is created and the id property is set on the context, the notification triggers and the binding is re-evaluated. During that binding evaluation a QObject property access happens by index on an object that doesn't have its VME meta-object set up yet. Therefore the property access fails and a crash occurs or the Q_ASSERT(property) assertion fails. The fix is to set register the id named object in the context _after_ the VME meta-object is setup. Task-number: QTBUG-40018 Change-Id: Ic2d7b4a0c49635efe68e93f2f6c316eb65f0c309 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Protect some members in QQmlObjectCreatorLars Knoll2014-08-251-4/+6
| | | | | | | | | | | | | | | | Avoid dangling pointers when nested incubators are being used. Task-number: QTBUG-40437 Change-Id: I73922d2f373b2efbc00983305cdea9e8d60f0c41 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>
* | CleanupSimon Hausmann2014-08-151-2/+2
|/ | | | | | | | | Merge QV4::CompiledData::QmlUnit into QV4::CompiledData::Unit. For pure JS units it means a slight increase of memory usage by a few bytes, but overall it makes the code a lot simpler. Change-Id: Ib48927749720b056f004aac0fe22cb8ec729e3f6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix interaction of garbage collector with JS objects during QML type ↵Simon Hausmann2014-07-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instantiation It may happen that during the lengthy process of instantiating a tree of objects for QML, the garbage collector runs. For objects created by QML we support different ownership models, for example in QtQuick visual parents keep their visual children alive, despite perhaps a lack of QObject parentship. That ownership becomes active once the QML autoparent function has assigned the correct visual parent, which happens after object instantiation (after QQmlObjectCreator). Similarly when a composite type is created, its QObject parent is only set after all properties have been set. The root QObject is kept alive through a special boolean, but if the sub-objects aren't children yet, their JS wrapper might get deleted. For composite types with var properties, that also means their var properties get deleted, such as the model property of TableView.qml in the bug report. In the future we want to support creating QWidget hierarchies with QML, which also for layouts may rely on a delayed parent assignment for layouts. To accommodate all this, this patch introduces an array on the JS stack that keeps track of all JS wrappers for all QObjects created. This array is alive during object tree creation. Afterwards, the different ownership models take over, for example the auto parent function assigning a visual parent. This patch also fixes an off-by-one in the total object count calculation for composite types, where when instantiating a composite type as a sub-object we counted the sub composite's object count but forgot the object itself. Task-number: QTBUG-38835 Task-number: QTBUG-39966 Change-Id: I6104b2434510642081e0c54793ed296adeca7481 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix crash when deleting component in Component.onComplete through loaderSimon Hausmann2014-06-231-2/+16
| | | | | | | | | | | | | | This is a regression introduced with Qt 5.3.0. The recursion watcher code that is supposed to handle the test case of QTBUG-39775 can detect the recursion into the object creator. However the boolean that indicates the recursion is a member of a structure that's deleted afterwards. To avoid access to deleted memory, this patch simply reference counts data structure shared between the creators and also wraps the recursion watcher into a convenience class that also increases/decreases the reference count accordingly. Change-Id: I8d2e3e200ab1295e89d951e09f187d382a056d5a Task-number: QTBUG-39775 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix crash with lazy binding initialization and compile time calculated ↵Simon Hausmann2014-03-171-1/+1
| | | | | | | | | | | | | dependencies During lazy binding initialization we may execute bindings where we calculated dependencies to the context object at compile time. In order to register those dependencies, the contet object needs to be set in the QQmlContextData. This patch makes sure to set it before setting up the bindings. Change-Id: Iacd360140cd9c389487bda82f6a7e6cc3a44c154 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix property caches out of sync with grouped properties that have a VME meta ↵Simon Hausmann2014-03-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | object Because QQmlObjectCreator::populateInstance would take the property cache to install from the outside and also pass it as the cache to use for the VME meta object to install, it could happen that the wrong cache was installed - the one supplied by engine->cache(propType) instead of the cache created together with the VME meta-object at type compilation time. This patch ensures that they're always in sync and correct by removing the responsibility of the caller to supply the cache to use and install. Instead the function will always use the cache calculated at type compile time (and also use that when installing the VME meta object). Installation of the property cache on the declarative data of the instance is now done only at createInstance() time, which fortunately also simplifies the code. Change-Id: Ia722cd57bc48007aaf725f1f59daa2f21569e324 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Add support for deferred propertiesSimon Hausmann2014-03-051-0/+1
| | | | | Change-Id: I592518444ef353cfcf153df0e6afa2fbac613560 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix profiler supportSimon Hausmann2014-03-041-0/+3
| | | | | | | | | Add profiler tracing calls during objection creation and make sure to set the function token / source location correctly for the synthesized function declarations of signal handlers. Change-Id: Ie4f8accce3a5c5d1d57bb0646cda588b89b76718 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix some qqmlincubator testsSimon Hausmann2014-03-041-2/+15
| | | | | | | | | | | | | | | We need to track the objects created and pass them over to the VME guard used in the incubator. The incremental build nature of the incubator requires that to avoid crashes. For nested incubators we need to set the activeVMEData field in the root QQmlContext, to allow child incubators to locate the parent. Lastly we need can emulate most of the VME behavior in terms of build states when running with QQmlInstantiationInterrupt by presenting four build steps: The initial state, two build steps, a finalization step and the state when we're done. Change-Id: I16cd7f71744decb9d4735ec77e9d944fad18e88d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix tst_qquickloader::deleteComponentCrash by introducing a ↵Simon Hausmann2014-03-031-0/+2
| | | | | | | watcher for self-deletion Change-Id: I809a4860831847ab61c7ca0ba302057ec165ee24 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Work around MSVC having issues with nested classes and templatesSimon Hausmann2014-03-031-12/+12
| | | | | | | Move SharedState into its own top-level structure. Change-Id: I0b6baeade57ff342df23672808d77933fa6ad26d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix for tst_qqmlconnectionsSimon Hausmann2014-03-021-2/+4
| | | | | | | | | | | | | Make sure to pass onFooChanged handlers to QQmlConnection's custom parser by not relying on the signal handler converter to set the IsSignalHandlerExpression flag. That should only be set for real signal handlers, the custom parser gets the raw bindings. Also don't try to initialize bindings at creation time the custom parser covers. Change-Id: Iae22bc886c312843136f073959e59da440f4184c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix QQmlPropertyMap testsSimon Hausmann2014-03-021-1/+1
| | | | | | | | | QQmlPropertyMap is treated as a type that cannot be cached with QQmlPropertyCache, doesn't allow for accelerated property access and also doesn't allow for declarations of any kind in sub-types. Change-Id: Id8a6811120aa61ffb5037394e758cc62501e0fc3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix qquickanimation test crashSimon Hausmann2014-03-021-1/+2
| | | | | | | | Share finalization callbacks across all sub-instances of ObjectCreator, by moving into into SharedState. Change-Id: Ibcd679caecd2009b4705d04c859b2fea4c2295fd Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Match class and file nameSimon Hausmann2014-02-161-5/+5
| | | | | | | QmlObjectCreator -> QQmlObjectCreator Change-Id: I23da2d9c7fa0dcd760f5cc695c1759b44d1e72f0 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Cleanup object creator membersSimon Hausmann2014-02-161-15/+21
| | | | | | | | Collect variables shared across recursive instances in a SharedData structure, get rid of some other members. Change-Id: I8d52fbb34820ce17d754b91c3fdee9e534a95753 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix component attachment linking across sub object creatorsSimon Hausmann2014-02-071-1/+2
| | | | | | | This brings up the list view in the components gallery. Change-Id: Ib91ca3b30b8093acad0343b47be60cf4b51e4da7 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix tst_qqmlincubator::deleteContextSimon Hausmann2014-02-071-0/+2
| | | | | | | | Protect against QQmlContext deletion during incubation re-using the existing QQmlContextGuard. Change-Id: Ia1c0241029765cc2e00a9b0ffcf484127de20606 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Allow for interruption during object finalizationSimon Hausmann2014-02-071-1/+2
| | | | | | | | | The object tree construction and binding allocation remains synchronous, but the initial evaluation of the bindings is now cooperatively interruptible again, like in the VME. Change-Id: Idd037dd481782c81ad43e20e93d922eb12ac8b85 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix parser status and created bindings allocationSimon Hausmann2014-02-071-7/+8
| | | | | | | | | | | | | | | Pre-calculate the amount of space we need for binding and parser status callbacks at compile time and therefore use a much simpler data structure (vector) to store the points to the bindings and callbacks. They need to be stored because during object construction and binding enabling phase, it may happen that they get destroyed and thus their m_mePtr pointing into the array gets deleted. The contiguous vector will also make it possible to interrupt the completion phase. Change-Id: Ic7c985bb8325ab355112e30e9d33d6ae4e7476d1 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix propagation of imported scripts for anonymous componentsSimon Hausmann2014-02-051-1/+2
| | | | | | | | We must take the imported scripts from the creation context. Fixes various errors in Qt Quick Controls. Change-Id: I336d8ffa0537cefd4eeac15f98bbf1b0a5c784af Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Set the rootObjectInCreation flag correctly on the root objectSimon Hausmann2014-02-041-1/+1
| | | | | Change-Id: Iaf96dabb1b3de81aae75953fd261dfc3b562169c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix refcounting leaks with property cachesSimon Hausmann2014-01-201-1/+1
| | | | | | | | | | | The TypeReference is not copy-safe, as it holds refcounted property cache pointers. For the new compiler code path, don't copy them but keep pointers to TypeReference objects around. Also make sure to ref the root property cache correctly and avoid the unnecessary addref for the property cache when creating new vme meta objects (initial refcount is 1). Change-Id: I0c4b952c8300c2167d926d9c35b8579fd505d596 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Clean up property cache / meta object builderSimon Hausmann2014-01-171-2/+2
| | | | | | | | Move the outter loop into the builder class itself, use a vector instead of a list (we know that it's a fixed size and we only do indexed access) Change-Id: I933f0496ea47b3bc7c2bebde7f1a14b4f603b4c3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix scope, binding target and property object for bindings in ↵Simon Hausmann2014-01-141-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | group properties Resolve the confusion about _qobject and _qobjectForBindings, use _qobject for all property related bits and _qobjectForBindings is gone, in favor of _scopeObject. Usually they are the same, but in group properties for example, the _scopeObject remains the outter object but the _qobject becomes the object that's returned by the group property, i.e. anchors.fill: parent For that binding, the scope object is the outter object but the _qobject is the value of the anchors property. Then there's binding target, which is revelant for value type properties, where it remains the outter object. In theory one could nest a value type property in a regular group object, in which case _scopeObject would be outter most, _qobject would be the value type wrapper and _bindingTarget would be the group object. Change-Id: Ie3135d951910bf40ece192ab6260d7a9e6e9cdd6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] CleanupsSimon Hausmann2014-01-101-71/+0
| | | | | | | | Move all compilation phase related sub-classes (property cache generator, component and alias resolver, etc.) together into qqmltypecompiler.cpp Change-Id: I598c801d9434623fc8e6338dec11e4d4ee6d7232 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Add support for implicitly defined componentsSimon Hausmann2014-01-101-5/+9
| | | | | | | | | | | | | | | Use-cases like itemDelegate: Item { ... } implicitly define a component without the item-surrounding Component {}, base on the fact that the property itself is of type QQmlComponent (or derived). This means we have to synthesize a Component {} object and insert it into the data structure. Change-Id: I8992451a5a6732c7fd898eaf83c276dc6a8b7d19 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] CleanupsSimon Hausmann2014-01-101-32/+12
| | | | | | | | Tie QQmlCompilePass and QQmlTypeCompiler together, so that we can eliminate the battery of parameters to the individual compiler phases. Change-Id: If2b6cf8416e6c2253c8f054048d1fd5ae12282b6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Move component determination and alias resolvingSimon Hausmann2014-01-091-8/+15
| | | | | | | | | Move the code before the JS code generation, as we are going to need the component boundaries for the correct scoping. This requires the component and alias resolver to operate on the pre-compiled-data data structures. Change-Id: I8d2e697d8a05e5a4914db93e785704f6b2434a2e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix signal handlers for properties declared in the same objectSimon Hausmann2014-01-081-3/+5
| | | | | | | | | | | | We need to generate the property caches before we can try converting the signal handler expressions in the AST to function declarations, as that conversion requires looking up the signal signature / meta-data from the property cache. This in turn requires rewriting the property cache generator code to operate on the data structure we have before creating the QV4::CompiledData. Change-Id: I0d1c59d947f36171b4eb89f47a2e1ff1bc493c6f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Initial support for custom parsersSimon Hausmann2014-01-081-1/+3
| | | | | | | | Enough to support the Connections {} element. What's missing are pre-compiled bindings signal handlers. Change-Id: I3ad1413fa636434d899ae8fb380249aaf40363dc Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Preliminary support for QQmlIncubatorSimon Hausmann2014-01-081-1/+2
| | | | | | | | Just enough to run some unit tests that use QQuickLoader, components are created instantly. Change-Id: I1c827aa946d3e2a60ccc220bb79572aca2ed8c96 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix determination of id objects within component boundariesSimon Hausmann2014-01-061-3/+3
| | | | | | | | | | | Don't draw the boundaries at Component {} level but at the level of the element inside the Component, so that we can still get the id of the Component element itself within the surrounding scope. Also removed unused data structure. Change-Id: I29e086e92f0310a38ba0a71224329f7399b397b2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Add support for parser status callbacksSimon Hausmann2014-01-061-0/+2
| | | | | Change-Id: I62ce1fab2537d533d1d2052a7f5edc5061adf75e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix error messages when assigning to non-existent properties in new compilerSimon Hausmann2013-09-301-0/+21
| | | | | | | | | Introduce a simple valdator pass early on to catch those assignments. Also fix storing the correct line/col for default property object bindings and remember the minor/major version of an import in the final type reference. Change-Id: Ib2a93dfe1a30fcd9c09b5443fb8199ad11b19769 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix component boundary detectionSimon Hausmann2013-09-251-0/+3
| | | | | | | | | | | For a component boundary, the type in question has to be an actual QQmlComponent. If it's a type that itself is derived from a component (type == 0 && component != 0 in typereference), then it is not a boundary. Fixes tst_qqmllanguage::componentCompositeType Change-Id: I938abe94c2fa4c69788176235ac74d0c6e385c0c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix bindings on properties in grouped value type propertiesSimon Hausmann2013-09-251-1/+4
| | | | | | | | | | | | | ... such as point.x: { someExpression } This requires special handling to install the QQmlBinding not on the value type itself (not possible) but on the point property itself. Fixes tst_qqmllanguage::valueTypes Change-Id: I8f95379e1872dff7cdcc0480c229a5e68f3cf575 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Initial support for alias propertiesSimon Hausmann2013-09-201-5/+14
| | | | | | | | | Aliases are resolved at "compile time", not rough JS expressions. This is done right after we determined the scope of components in the QML file, which is also where we collect object ids (that aliases use). Change-Id: If5702337f2cca08d17f196c3b2fde3bbdfea5b3c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix scope object for binding expressions in signal handlers ↵Simon Hausmann2013-09-201-1/+1
| | | | | | | | | | | of attached objects In populateInstance the QObject instance to populate with properties, etc. may not necessarily be the scope object (in qml lookup terms), so it needs to be provided as a separate parameter. Change-Id: I05db123c249e8582469bcfb76f56eb3f7bfbc4a2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Initial support for composite typesSimon Hausmann2013-09-201-1/+1
| | | | | Change-Id: I01030814a978d8a52a086b0389fe62af42a4bbba Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Initial support for componentsSimon Hausmann2013-09-201-8/+30
| | | | | | | | | We use a dedicated pass through the objects in QV4::CompiledData::QmlUnit to determine which objects are QQmlComponents. We remember their object indices as well as to which component other objects belong to (if any). Change-Id: I97929c57e2ccb2fd380d612002d128359c4bc253 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] CleanupsSimon Hausmann2013-09-201-18/+17
| | | | | | | | Collect code for collecting errors and string access for different compile passes (vme creation, qobject creation) in a QQmlCompilePass base class. Change-Id: Ib2119e730ce7d3181599ba29da12273f041f2b70 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] CleanupsSimon Hausmann2013-09-201-3/+4
| | | | | | | | | Make the v4 context to use for binding expressions/functions/signal handlers a member variable instead of a function parameter, as it doesn't change frequently. Change-Id: I8a73bbc3f37c116d29172d5c935c66ecf2f67a38 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Finish support for initializing list propertiesSimon Hausmann2013-09-201-0/+2
| | | | | | | | | | | | | | | | Setting a value on a list property is always just appending to the list instead of replacing it. Based on that, initializing list properties with multiple items is done with one binding per item to the same list property. So myList: [ Item{}, Item{} ] is mapped to myList: Item {} myList: Item {} Change-Id: Iadc048ab3a8d73ac824aa6b2ae5dec33731fa362 Reviewed-by: Lars Knoll <lars.knoll@digia.com>