aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlcomponent.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Immediately complete component upon creation failureFabian Kosmale2022-06-081-1/+9
| | | | | | | | | | | We do not want to wait until reaching the Component destructor (at which point e.g. the engine might be gone). Change-Id: Ic0e4383ec4e3759d9f02847413a25191a01286cb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 759090f59140d0b38c7bd57480ea6cd93d4cf0d3)
* QML: Port QV4::CompiledData::Location to new special integer bitfieldUlf Hermann2022-05-171-2/+4
| | | | | | | | Task-number: QTBUG-99545 Change-Id: If0d6f893f2351a4146ddf125be4079b5e312f308 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> (cherry picked from commit 893b6ae6e890a2b8fc842d9c9cc64b9b8f34e22f)
* (manual) includemocsMarc Mutz2022-05-101-0/+1
| | | | | | | | | | | - moc_qqmlcomponentattached_p.cpp → qqmlcomponent.cpp Fixes: QTBUG-102948 Change-Id: I54c2932416d3f3699772b85ba96134b0ef1b6a9e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 79daf29782b1f9596508de201a677214a31200a5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Handle property assignment failure for group property gracefullyFabian Kosmale2022-05-071-1/+4
| | | | | | | | | | | | | | | With grouped properties, we might end up with a completePending state afer construction failed. If the engine then is deleted before ~QQmlComponent runs, we then have a null creator pointer in the state (see the connect to QObject::destroyed in the ctor). Use an if check to guard against this. Fixes: QTBUG-102425 Change-Id: Iec27cb003a81b1f72317b87297832025c74cbfe9 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit ed7dd5ad011436cafda58e7fd434bda575cff1b9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QQmlComponent: Skip the logging loop completely if category is not enabledIvan Tkachenko2021-11-021-2/+3
| | | | | | | | | This is meant as an optimization. Pick-to: 6.2 Change-Id: Ied55c6177669165b82b871ff89703b69336e81b6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Doc: Fix core QML functions signatures and examplesIvan Tkachenko2021-11-021-62/+64
| | | | | | Pick-to: 6.2 Change-Id: I539e54a9a44b65ea9ff50a78c3cfa711860874d4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlComponent: Make it harder to leak deferred statesUlf Hermann2021-11-011-9/+9
| | | | | | | | The previous pointer wrangling was ripe with foot guns. Let's just use a vector of unique_ptr to keep track of the states. Change-Id: I3ae225b3ab8644aa690d506d0a5de0bfb9ecce23 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Provide a non-QQmlV4Function version of Component::createObject()Ulf Hermann2021-10-211-9/+93
| | | | | | | | | | | | | | It actually just takes a parent object and a list of parameters, both optional. We don't need varargs for that. It now warns if you pass more parameters, but that is a good thing. As the QQmlV4Function variant accepts a number of questionable values in addition to QObject* and QVariantMap, we need to retain it. Change-Id: Id39c07b890e4d2964ddb2cc498f56f2fe483e887 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Improve type conversions from/to QJSValueUlf Hermann2021-10-201-4/+8
| | | | | | | | | We can convert everything into a QJSValue if we have an engine and we can save a binding function in a QVariant by wrapping it into QJSValue. Change-Id: I48e7c13f3f744f1c50bf673b427fe9331250f313 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Eliminate JS call frame from metatypes callsUlf Hermann2021-06-101-1/+1
| | | | | | | | If we call an AOT-compiled function we never need the JavaScript call frame. We can just skip its setup and save some overhead. Change-Id: I39dc2ca6eea5b5a66f3b87b642a310534cecf6cd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlComponentPrivate::setInitialProperty: improve error messageFabian Kosmale2021-04-271-2/+7
| | | | | | | | | We can discern between the case where the property does not exist at all, and the case where we cannot set it. Pick-to: 6.0 6.1 5.15 Change-Id: Ia2e8f4cc077a00b90d720db01bff1542a812dea0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Document QQmlComponent::createWithInitialProperties() error handlingMitch Curtis2021-04-271-0/+8
| | | | | | | | Unlike create(), it can produce errors that should be checked. Pick-to: 5.15 6.0 6.1 Change-Id: I78f2e58c8666eb45f6e850c43e3e97a448b2758e 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>
* Log errors in QQmlComponentAndrei Golubev2021-03-051-0/+9
| | | | | | | | | | Add logging to QQmlComponent::create(). For instance, this handles cases when errors (non-logged) occur before the QQmlObjectCreator. What would typically be written is "QQmlComponent: Component is not ready", which is, well, not helpful Change-Id: Ia7aabe68d8f42f64b00528a3559830f54a3821d8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlComponentPrivate::setInitialProperties: Do not silently swallow exceptionsFabian Kosmale2021-01-181-2/+2
| | | | | | | Instead, log them with qmlWarning. Change-Id: Icde7397085841a84aca8a81c716d552c4cd4485a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlComponent: Avoid crash when setting initial properties in JS moduleFabian Kosmale2021-01-151-1/+2
| | | | | | | | | | In a JS module, we lack a qml context. Thus, we have to check whether qmlContext is null. In that case we use the engine's scriptContext('s ExecutionContext) instead. Fixes: QTBUG-90245 Change-Id: I337e9c7cade472f52fc81c93d1152ff59f8018a5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Rename QQmlQPointer to QV4QPointerUlf Hermann2020-09-211-1/+1
| | | | | | | You can wrap QObject pointers in plain JavaScript. Change-Id: I246a72a7d5d7b2562e722bf9eafc7880b772a806 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Encapsulate QQmlContextDataUlf Hermann2020-03-231-26/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove hard-coded notes for 'Corresponding handler' for QML signalsTopi Reinio2020-03-101-6/+4
| | | | | | | | QDoc will generate these notes automatically. Task-number: QTBUG-37355 Change-Id: I8ed058ecbbcc630ad0351f6ce167c3fa61936f6f Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Restore offset/length in QQmlJS::DiagnosticMessageSimon Hausmann2020-03-021-2/+3
| | | | | | | | | | | | This is needed in a few places outside of declarative, so this change restores the loc member in DiagnosticMessage and moves QQmlJS::AST::SourceLocation into common's QQmlJS namespace/directory. QQmlError is unaffected and retains only line/column. Amends d4d197d06279f9257647628f7e1ccc9ec763a6bb Change-Id: Ifb9d344228e3c6e9e26fc4fe112686f9336ea2b2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid initializing QFlags with 0 or nullptr in further casesFriedemann Kleint2019-11-251-1/+1
| | | | | | | Amends 744e77b841878fb017c0f2d60607090008f28180. Change-Id: I16e37aaf503eb62f67fca0e48be4c92c4a72ae46 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlObjectCreator: Unify deferred setup of bindingsUlf Hermann2019-10-161-0/+1
| | | | | | Change-Id: I5e9ff550aa2875f41dbea797d814e1f0044ebd63 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-10-041-3/+4
|\ | | | | | | | | | | | | | | Conflicts: src/imports/qtquick2/plugins.qmltypes src/quick/items/qquickitemsmodule.cpp Change-Id: I841c65c9c131354788b4f3fcfe3d7ed27be316d5
| * doc: Fix several qdoc warningsMartin Smith2019-09-231-3/+4
| | | | | | | | | | | | | | | | This update repares several "Can't link to...," "No such parameter...," and "Undocumented parameter..." warnings. Change-Id: I3649cf35f766e5a87ca5df48301e8063a31d7904 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | qquicklistview: support required properties in sectionDelegateFabian Kosmale2019-09-121-0/+5
| | | | | | | | | | | | | | | | | | | | This changes the accessibile properties in the sectionDelegate: If the sectionDelegate contains requiredProperties, "section" will not be injected into a newly created parent scope. Instead, the section property of the delegate will be set if it exists. Change-Id: I34b04d08d2f80af7ea53fd722f08be0f9aea6e72 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Introduce required properties to QMLFabian Kosmale2019-09-091-10/+119
|/ | | | | | | | | | | | | | | | | | | [ChangeLog][QtQml] "required" is now a (contextual) keyword in QML, and users can mark properties with it to specify that those properties must be set when the component gets instantiated. This can be done either declaratively via standard property bindings from QML, or imperatively by using the functions to set initial properties (QQmlCompoent::setInitalProperties and related functions in C++, Qt.createObject, Loader.setSource,... in QML/JS). Logic has been added to QQmlComponent::create and the various QQmlIncubator classes to verify that the required properties were set. If properties marked as required are not set, a warning will be printed at runtime, and the component will not be created. Change-Id: I8e38227fc8f173b053b689c1597dc7fd40e835e7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Introduce functions to set properties during creationFabian Kosmale2019-08-191-9/+65
| | | | | Change-Id: Idd4c8ab9e34b9bc3e00f21d7cf1e4f1a70586e7f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-07-121-0/+12
|\ | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmltypeloader.cpp src/quick/scenegraph/qsgopengldistancefieldglyphcache.cpp Change-Id: I1a226d8738db2ec06e3cef240a0e040e7c144cad
| * QQmlComponent: Check for existence of engineFabian Kosmale2019-07-031-0/+12
| | | | | | | | | | | | | | | | | | | | Avoid a crash when setData or create are called after a user mistakenly used the internal constructor of QQmlComponent which does not take an engine. Fixes: QTBUG-55407 Change-Id: Ia4295d1b044723efce1a95607349561d4f1640da Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Remove qqmlmemoryprofiler*Ulf Hermann2019-06-131-2/+0
| | | | | | | | | | | | | | | | | | | | I've never seen it used and I've never seen the companion library required to operate it. Change-Id: I5a0e6aed9a416f1bd26dea97def9667a11a4d77d Reviewed-by: Robin Burchell <robin.burchell@crimson.no> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Michael Brasser <michael.brasser@live.com>
* | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-06-111-1/+1
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4value_p.h src/qml/qml/qqmlmetatype.cpp src/qml/qml/qqmltypewrapper.cpp src/quick/items/qquicktableview.cpp Change-Id: I684f8e01a711580512848bf1253f39b39fcbf4c7
| * Doc: Remove superfluous double quotes in code snippetsPaul Wicking2019-06-041-1/+1
| | | | | | | | | | | | Fixes: QTBUG-75957 Change-Id: I2c9c70461a828978d1413b8cbdb407663b4b7493 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* | Split CompiledData::CompilationUnit in twoUlf Hermann2019-05-161-1/+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>
* | Remove last traces of QV8EngineUlf Hermann2019-05-081-1/+1
| | | | | | | | | | Change-Id: I59f738402d51e39188bbbca2ef1fbc8a61612372 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>
* Documentation: Start using the \nullptr macroFriedemann Kleint2019-01-211-4/+4
| | | | | | Task-number: PYSIDE-903 Change-Id: I0c4640eb20157673eabb131e8834e79cbbf95d5c Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Hold internal reference to incubator object while incubatingMichael Brasser2018-10-261-7/+11
| | | | | | Task-number: QTBUG-53111 Change-Id: Ifaef6a855914d79155f8028b0de7ccca3c9a00f5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Doc: Remove references to Qt Quick 1Kai Koehne2018-10-011-2/+0
| | | | | | | | | | Qt Quick 1 is dead since Qt 5.0, so it doesn't make much sense anymore to link to different names there, or highlight behavioral differences. Task-number: QTBUG-70780 Change-Id: Iac5e0b226621f127714e722a11208ca1b21d977f Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-5/+5
| | | | | | | | | | | | 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>
* Remove support for iterating over the proto chain from ObjectIteratorLars Knoll2018-08-021-1/+1
| | | | | | | | | This will simplify moving over to the new iteration model. It implies a very small behavioral change in a few places where we used to iterate over the proto chain before. Change-Id: Ia62c9c51712d6b45e69ca63becdbefab6fa4bf3f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add QQmlEngine getter to QQmlComponentFrederik Gladhorn2018-07-311-2/+13
| | | | | Change-Id: I1c9979fbd5ca81700ec7ad60e6d991e70c6d5fb5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge "Merge remote-tracking branch 'origin/5.11' into dev" into ↵Liang Qi2018-06-251-2/+2
|\ | | | | | | refs/staging/dev
| * Merge remote-tracking branch 'origin/5.11' into devUlf Hermann2018-06-251-2/+2
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp src/quick/handlers/qquickhandlerpoint.cpp src/quick/handlers/qquicksinglepointhandler.cpp tests/auto/qml/ecmascripttests/test262 Change-Id: I8908ec8c6116ca626fbd269af7625d4c429429ca
| | * Doc: Add missing dots (qtdeclarative)Paul Wicking2018-06-191-2/+2
| | | | | | | | | | | | | | | | | | Task-number: QTBUG-68933 Change-Id: Ibb5aa227e82825085e7214e17dcffcb17fd44157 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* | | Add Proxy support for prototype handlingLars Knoll2018-06-251-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | Cleanup get/setPrototypeOf and fix some smaller incompatibilities in the default implementation for Object. Add the methods to the vtable and reimplement them according to spec for ProxyObjects. Clean up the Object.prototype.get/setPrototypeOf/__proto__ methods and fix a smaller bug in the Reflect API for those methods. Change-Id: I6e438753332ec4db963d6cdcf86f340ff212777a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Allow partial creation of more than 10 QQmlComponent instancesRichard Weickelt2018-05-181-13/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The recursion detection in QQmlComponent erroneously triggered when calling beginCreate() on >= 10 different instances. This may happen by intention and is not necessarily a sign of recursion. Since beginCreate() does never invoke a potentially nested Qt.createComponent(), but completeCreate() does, it is better to modify the creationDepth counter in completeCreate(). This also leads to simpler code. The test, however, can remain in beginCreate(). Task-number: QTBUG-47633 Change-Id: If413a8b08421d321d6a426ec16600996cb3f6ea1 Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au> Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Clean up manual reference of QQmlTypeData and QQmlPropertyCacheSimon Hausmann2018-04-261-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Disambiguate different allocation functions in the memory managerLars Knoll2018-04-121-1/+1
|/ | | | | | | | | | | Some compilers (in this case MingW 5.3) don't manage to properly disambiguate the template overloads, and try to instantiate the wrong template function. Solve this by renaming the one of the template functions. Change-Id: I3574e617fe96c4bd52920a0127a1dfe39cc3d302 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix crash when QML engine warning handler feeds errors back into QMLSimon Hausmann2018-04-091-2/+1
| | | | | | | | | | | | | | 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>
* Improve documentation on component creation contextMichael Brasser2018-03-081-0/+3
| | | | | Change-Id: I55adc9c261529ee4b88fbb5591b3955e396437a8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>