aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Support and prefer QML_IMPORT_PATH over QML2_IMPORT_PATHUlf Hermann2021-02-102-29/+35
| | | | | | | | | | The 2 is meaningless. Task-number: QTBUG-85064 Change-Id: I9f140155d274c691b5eab1285d9b7153f9f93a87 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use QLibraryInfo::QmlImportsPath rather than Qml2ImportsPathUlf Hermann2021-02-092-4/+4
| | | | | | | | | The "2" is meaningless and there is a better name available now. Task-number: QTBUG-85064 Change-Id: I65d26b06712ed7dcf2825f16dffaa6060dd86985 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* qqmlengine: Fix some warnings not being displayed correctlyMaximilian Goldstein2021-02-091-8/+8
| | | | | | | | Use noquote() for qqmlengine warnings. Fixes: QTBUG-86595 Change-Id: Ibe161cb164b9fa2511e4bc02237de5d81172e114 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Return errors if validation of inline components failsUlf Hermann2021-02-081-1/+3
| | | | | | | Pick-to: 6.0 6.1 Fixes: QTBUG-90038 Change-Id: Ic01b5d097e0b9e6720bcec7ccb18c22abb5418f4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlInterceptorMetaObject::intercept: Avoid metatype<->id ping-pongFabian Kosmale2021-02-081-4/+3
| | | | | | | | | | There is no need to extract the metatype id to know whether the type is valid (aka != UnknownType). Moreover, as we already have a metatype, there is no need to do the typeid -> metatype lookup. Task-number: QTBUG-88766 Change-Id: I5f9512aa6e06b0d89be8d3cad970f12319dab156 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qqmlproxymetaobject: Support invoking methods and slotsMaximilian Goldstein2021-02-052-31/+55
| | | | | | | Previously this just failed silently and returned garbage data. Change-Id: Ia8b72836aa0ccfd50fd18b0f813c2bf3a00801c5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use a QDoubleEndedList for the children of animation group jobsUlf Hermann2021-02-051-0/+292
| | | | | | | | | | This way it's fundamentally impossible to add the same animation job to two different group jobs. The pointers are not exposed anymore and no one can re-order the jobs. Task-number: QTBUG-90401 Change-Id: Iebff4b64960c853915dd32714acd144fc5cdc00d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlIRLoader: Actually load RequiredPropertyExtraDataFabian Kosmale2021-02-031-0/+7
| | | | | | | | | | | | | | | If a QML component wants to mark properties of its "parent" component as required, it can do so via required propertyName The information about those properties is stored in a RequiredPropertyExtraData data structure. This structure is already serialized to disk in the QQmlIRWriter. However, we neglected to restore it so far in the loader. Fixes: QTBUG-90538 Pick-to: 5.15 6.0 Change-Id: I789daff9bc881e4f35c942c77f5116b5284de81b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Allow for multiple extensions per objectUlf Hermann2021-02-011-1/+2
| | | | | | | | | | | | | | | | | | | Previously, the assumption was that each object could only have a single extension object. As proven by the new qqmllanguage test this is not the case. Each registered object in the type hierarchy can have its own extension. Therefore, adjust the algorithms that generate qmltypes and iterate the extension objects when analyzing them. This leads us to the realization that anonymous types can in fact meaningfully carry extensions and implement interfaces. Adapt qmltyperegistrar accordingly. For the test to compile, however, we need to realize that the class declaring interfaces needs to befriend all potential subclass's QmlInterface structs. Fix that, too. The rabbit hole went deep. Change-Id: Ia451897e927e03b95c3062e829edf1dfcd216613 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move implementation of functions declared in qqml.h into qqml.cppUlf Hermann2021-01-292-74/+76
| | | | | | | | It makes no sense to have them qqmlengine.cpp. Change-Id: I138807c7650ec7aef4c6e8833e8bac8a6f179d1c Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QML value types: Properly apply the QML_EXTENDED trick everywhereUlf Hermann2021-01-291-0/+5
| | | | | | | Without this, the properties of those types are invisible to tooling. Change-Id: Iffd05643a650d03993d9fe1a3783fe3db8c33f0b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* fix not initialized enum error valueTim Jenssen2021-01-261-1/+1
| | | | | | | amends: c0b59369ab45a78e4407633365a52c1a9255512c Change-Id: If068443257baa0eaee31a43b94b2e0d0f7f554fe Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Allow AOT compiled functions to set the instruction pointerUlf Hermann2021-01-262-2/+8
| | | | | | | | This way we get correct line numbers in error messages. Change-Id: Ieb642523f74adf73955e78cdfb8cb2faee40b321 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltyperegistrar: Make sure we have metatypes for all QML typesUlf Hermann2021-01-251-0/+24
| | | | | | | | | | We need to be able to resolve any QML type from its C++ name using QMetaType::fromName(). qmltyperegistrar can generate the missing metatypes, either by creating synthetic ones (for namespaces), or by making sure the existing ones are registered (for others). Change-Id: If775af56d891f2c2a5bb94589b3cb05a199c7c35 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlPropertyCache: use more efficient addProperty overloadFabian Kosmale2021-01-251-1/+2
| | | | | | | | | | As we already have the metatype of the property, we can use the more efficient QMetaObjectBuilder::addProperty method which avoids a name to metatype lookup. Task-number: QTBUG-88766 Change-Id: Iab8c22556cb15d35337f266e533cb0d907232421 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Don't register invalid metatypes in QQmlMetaTypeDataUlf Hermann2021-01-251-5/+0
| | | | | | | | If the original type's ID is not valid, then QQmlMetaTypePrivate's ID is also not valid. Change-Id: Ia727e7dc99b1954b4c6fa9b599e8edc0ef9b3212 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move qmlRegisterUncreatableMetaObject to qqml.cppUlf Hermann2021-01-252-34/+33
| | | | | | | | | There is no reason to keep it in qqmlengine.cpp as it is declared in qqml.h. Change-Id: I0a0261b943c4a3b4333d7161becbd68ad4f1b21e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QQmlPropertyBinding: improve error reportingFabian Kosmale2021-01-253-7/+77
| | | | | | | | | | | | | | | | | | This change ensures that bindings created in QML between new-style properties contain information about which property caused the loop. To do this, we store additional information about the property involved to retrieve its name and position at a later point. We print the warning in case we detect a binding loop in evaluate, and also set the error reporting callback correctly, so that the condition can be reported when the loop is detected in another part of the binding evaluation. In addition, we do not only set the QPropertyBinding's error member when JS evaluation results in an error, but also print the warning with qmlWarning. Fixes: QTBUG-87733 Change-Id: Idb25237d1f57355ca31189e6bf2a918430b3a810 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Export QML and Quick value typesUlf Hermann2021-01-221-8/+8
| | | | | | | They need to be accessible from C++. Change-Id: I60f2213bdbe6b8b64856e13f1e0cc798f8a51086 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* fix no translation buildTim Jenssen2021-01-211-0/+2
| | | | | Change-Id: I5f4334e8b55511c33eab52262239d5d2da2329ba Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML_SINGLETON: Handle local create() functions with foreign typesMaximilian Goldstein2021-01-202-21/+34
| | | | | | | | Previously only the foreign type was searched for a create method. Now the wrapping type can also contain it. Change-Id: I05fb9e0c0a54c14530eb9adcae5a44df5c208be3 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>
* Remove the qmake project filesFabian Kosmale2021-01-153-228/+0
| | | | | | | | | Remove all qmake project files, except for examples which are used to test that qmake continues to work. Change-Id: Ic4abb72dc2dcd75df7a797c56056b6b3c5fe62ac Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Move QtObject out of the QV4 namespaceUlf Hermann2021-01-151-21/+22
| | | | | | | | This way we don't have to specially prefix the foreign namespace. Change-Id: I0daa2fe3b8faa205c2c9dfb0f6b1984b2c8e7437 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@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>
* Add a freeze() method to QQmlPropertyMapUlf Hermann2021-01-132-9/+22
| | | | | | | | | After freezing a QQmlPropertyMap you cannot add any more properties, but in turn the property access is cached, and therefore faster. Task-number: QTBUG-57792 Change-Id: I2c6d768039c3b59eb2411194e463ee0de55f8bed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove QQmlCleanupUlf Hermann2021-01-1310-236/+8
| | | | | | | | | | | | | | | | | The only place where it was still used is QQmlOpenMetaObjecType. The only effect of QQmlCleanup is that clear() is eventually called by the engine. In the case of QQmlOpenMetaObjectType the only effect of that was that the "engine" member was reset. However, the only place where that member was used was in setCached(), and in that place it was irrelevant. There is no reason why setCached() should be prohibited when there is no engine. We may be worried that the property cache assigned to the open metaobject might go away somehow if there is no engine, but the cleanup mechanism clearly demonstrates that checking for the engine on setCached() does not protect against this. Fixes: QTBUG-90004 Change-Id: I05445eaeb53a64c70de366090ea2ee4aecf2bad8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlPropertyMap: Add a method to insert multiple values at onceUlf Hermann2021-01-132-14/+63
| | | | | | | | | | | | This avoid re-building the metaobject for every property added. As rebuilding the metaobject is an effort linear in the number of properties, the runtime when adding multiple properties via singular insert() is quadratic in the number of properties. The plural insert() rebuilds the metaobject only once. Task-number: QTBUG-57792 Change-Id: I9513c4de047724e4141dab72aacfbdd840a3e465 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlListReference: Allow construction from a QVariantUlf Hermann2021-01-122-0/+37
| | | | | | | | | | | | Currently there is no public API to transform a QVariant holding a QQmlListProperty into a QQmlListReference. We cannot pass QQmlListProperty itself as that is templated. The metatype-based casting is somewhat evil, but not more so than what we already have in the other ctor. Change-Id: I2d56499b1fd188613bc71016cb00ec23081d3cea Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Make QQmlImport::removeDynamicPlugin() saferUlf Hermann2021-01-121-28/+24
| | | | | | | | | | | | | Consistently never unload plugins on macOS, also remove half-broken plugins from the map, and always unregister any types in them. Unloading plugins on macOS is ill-advised as it will actually unmap the memory, making string data (among other things) inaccessible. We've already done the same change to qmlClearEnginePlugins(). Change-Id: I8fa40db5c3cd83f12e6d85d0efc3b9679dd4381e Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove QQmlCleanup from QQmlScriptDataUlf Hermann2021-01-122-26/+1
| | | | | | | | | | | | It prevents the compilation unit held by QQmlScriptData from being released on clearComponentCache(). The comment justifying the QQmlCleanup has been wrong since we moved away from V8. Task-number: QTBUG-89659 Pick-to: 5.15 Change-Id: I220561d90f707540e47c76d60a51468ee231ce9a Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Pass a more comprehensive context to AOT-compiled functionsUlf Hermann2021-01-113-5/+25
| | | | | | | | | | We need the compilation unit, and a way to retrieve JavaScript metatypes from it. Also, prepare for cases where we only have a QJSEngine, not a QQmlEngine, and pass the scope object as part of the AOT context. Change-Id: Ica81e92c99f3c9b6baffd04db1e0e91603fd2ac7 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmlengine: Fix crash when encountering bad singletonsMaximilian Goldstein2021-01-111-0/+6
| | | | | | | | | Previously errors occurring when parsing QML singletons would just be ignored resulting in a crash. The errors are now properly printed and the execution is aborted in time. Fixes: QTBUG-85932 Change-Id: I61cef5f97546ce2e0753bc46c548838a21b1f506 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid crash for deep aliasesMaximilian Goldstein2021-01-111-0/+4
| | | | | | | | | Aliases are seriously broken and need a larger overhaul. This patch at least prevents the application from crashing. Task-number: QTBUG-89822 Change-Id: Ib6acc5b6f621a902f7f5ce370043986486f3c0d0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-12-165-5/+5
| | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtDeclarative. As the two are synonymous, this patch should have no impact on users. Task-number: QTBUG-86829 Change-Id: I5bb418483a3b06619abb4ff62cf0290a7b3bcd4f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qqmltypeloader: Allow pluginless qmldir + declarative type registrationFabian Kosmale2020-12-151-1/+9
| | | | | | | | | | | | | | Assume an application which uses a QML singleton (so needs qmldir), and wants to use declarative type registration. This currently breaks because we find the qmldir, see that there is no plugin to load, and thus never search for registration functions. Requiring the creation of a plugin is rather pointless for an application which doesn't reuse the QML types; so instead enable this usecase to work. Note that qmldir + imperative registration did always work, as the imperative registration code did always run. Change-Id: Iac40020eb97d602d10eb8c4eecac5195ffeabe14 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlMetaType: Remove lists setFabian Kosmale2020-12-112-6/+6
| | | | | | | | | | The information can be found in the metatype. Task-number: QTBUG-88766 Change-Id: I6c460e3100057498b17d9ed74d2e85b609a6ab4c Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlMetaType: Get rid of objectsFabian Kosmale2020-12-112-9/+6
| | | | | | | | | | | Use the information from the metatype instead. Task-number: QTBUG-88765 Task-number: QTBUG-88766 Change-Id: Ie0a748861388e8c36f5f607ccd5aba4d6049b930 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Clean up (QQmlEnginePrivate|QQmlMetaType)::toQObjectFabian Kosmale2020-12-112-9/+2
| | | | | | | | | | | | | | | All the necessary information is contained in the QVariant's metatype, so we can use that. This removes the need to acquire the data pointer lock. The method in QQmlEnginePrivate now simply forwards to QQmlMetaType; in a later commit, all usages of the forwarding functions from QQmlEnginePrivate will be replaced with the equivalents from QQmlMetaType, so that they can be removed from QQmlEnginePrivate. Task-number: QTBUG-88766 Change-Id: Iebcda9b18b4952fff2c7c1aeae210c677c6869b8 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Respect QML_DISABLE_DISK_CACHE also for caches built into the binaryUlf Hermann2020-12-101-5/+8
| | | | | | | | Previously it would only disable loading of separate cache files. Change-Id: Iae92fc03d2e5566ef7dc44a6730b788b7512fd3d Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Support namespaced QML_ELEMENTMaximilian Goldstein2020-12-101-2/+9
| | | | | | | Fixes: QTBUG-87266 Change-Id: Iad8c7765b339c5498f541702bbf7df64164f5358 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix IC properties in same fileFabian Kosmale2020-12-104-3/+37
| | | | | | | | | | | Also fixes typename and metatype registration for inline components. Done-with: Fabian Kosmale <fabian.kosmale@qt.io> Pick-to: 5.15 Fixes: QTBUG-89173 Change-Id: I97d65d5539b577a8828d5711e5f2e79c8568b441 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Fix occurrences of \Q_OBJECT in code snippetsTopi Reinio2020-12-083-73/+12
| | | | | | | | | | | | | | 'Q_OBJECT', even in a comment, interferes with automoc. Prefixing it with a backslash solves the automoc issue, but documentation looks wrong as content inside \code is taken verbatim. Move code snippets to doc/snippets and refer to them with \snippet commands. Pick-to: 6.0 Change-Id: Ied7fdf87ef5edd2b237498b91b162c19bf7bc636 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Allow the QML console methods to be called from outside JSUlf Hermann2020-12-071-3/+4
| | | | | | | There may not be a stack frame and that is OK. Change-Id: Iccac4db1530c9a4b316905a3a283d36674c146a8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML engine: Fix binding setupFabian Kosmale2020-12-031-2/+2
| | | | | | | | | | | We set QProperty bindings up in the wrong way: Parent components would overwrite their child component's binding. This patch reverses the order, fixing the bug. Task-number: QTBUG-87153 Pick-to: 6.0 Change-Id: I3e90d1d14a41a7c5c337745f1453484d360a3979 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML engine: Deprecate DefaultMethodFabian Kosmale2020-12-031-1/+7
| | | | | | | | | | | | | | | | | | | | | | Assigning objects to signal handlers can be convenient, as seen in the examples which use it together with ListView.onRemove. However, that convenience makes it hard to reason about what actually happens. Moreover, the only user of that functionality are the Animation classes, and the usage of DefaultMethod is not documented anywhere. [ChangeLog][QtQml] Assigning an object to a signal handler is deprecated. Instead, create the object, give it an id, and call the desired slot from the signal handler. For instance, instead of of ListView.onRemove: SequentialAnimation {...} use SequentialAnimation {id: removeAnimation; ...} ListView.onRemove: removeAnimation.start() A warning will be printed whenever an assignment of an object to a signal handler occurs. The warning can be controlled via the qt.qml.defaultmethod logging category. Change-Id: I001ddf4d7933871977f84a5e012d020fb043cc64 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Simplify QQmlPropertyCache::isDynamicMetaObjectFabian Kosmale2020-12-031-1/+1
| | | | | | | Qt 6 does not have metaobjects with revisions < 3. Change-Id: I525e88fa7a907240cd9553ad7b067a28a9793ae7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlValueTypeFactory: remove bespoke Qt type cacheFabian Kosmale2020-12-031-37/+21
| | | | | | | | | | | | | | QQmlValueTypeFactory contained an array of size QMetaType::User, to avoid locking for accessing user types. In Qt 6, User is however significantly larger, causing the array to take roughly 500 KByte of memory. We therefore unify the handling of user types and Qt built-in types, by storing all of them in a QHash. We replace the mutex with a read-write lock to still allow concurrent read access to the mapping (now for all types and not only Qt builtin types). Change-Id: Ie22786b0f33cf27157b151c75d5bb21579a566f6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlPropertyCache: Remove unused copyAndAppend overloadFabian Kosmale2020-12-032-13/+0
| | | | | | | Original-patch-by: Lars Knoll <lars.knoll@qt.io> Task-number: QTBUG-88765 Change-Id: I85dad61a1c3ade29137be9870ce8af726be81a28 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>