aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
Commit message (Collapse)AuthorAgeFilesLines
* Uniformly support shebangFawzi Mohamed2021-02-151-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | The "qml" tool was the only way of loading QML files that would respect a shebang line. This is problematic as this way you cannot load such files programatically using QQmlComponent, limiting their re-use. Common tools like Qt Creator, but also qmllint, qmlformat, qmlcachegen, etc would not recognize files with shebangs. By moving she-bang support directly in the lexer all tools implicitly support it. Note that we could just as easily support '#' as extra comment character along with //, but here we narrowly add support for in the first line only, as node does (this means that javascript files using she-bang accepted by node, are now accepted also by qml). The only tool needing some adjustments is qmlformat, that has to emit the she-bang again as she-bang and as first line. Add tests for qmlformat, and sprinkle some she-bangs in the other tests just to be sure it doesn't affect anything. Change-Id: I1f6d881c7438bdb23163b5dbe829d59a35d11132 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQmlPropertyBinding: Create more verbose binding loop warningFabian Kosmale2021-02-151-1/+6
| | | | | Change-Id: I6f83fc61c72993c04c99ff16c31c10b20ada5db8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Warn about usage of injected signal parametersUlf Hermann2021-02-129-23/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | You should declare functions with formal parameters if you want to use parameters passed by the signal. We need to generate two different warnings because there are two code paths by which such parameters are injected. If we compile with qmlcachegen, it simply inserts a lookup instruction in to the byte code. This lookup then triggers our special hack expressly made for signal parameters. If we don't compile using qmlcachegen, a function declaration with formal parameters is synthesized. We mark those formal parameters as injected and warn if we see one of them used. [ChangeLog][QML][Important Behavior Changes] The automatic injection of signal parameters into signal handlers is deprecated. This is because we cannot determine the names of the signal parameters at compile time. Furthermore, also for human readers it is difficult to discern between arguments, context properties, properties of the current object, and properties of the root object of the component. Requiring the signal parameters to be explicitly named resolves some of this confusion. You can turn the deprecation warning off using the "qt.qml.compiler" and "qt.qml.context" logging categories. Task-number: QTBUG-89943 Pick-to: 6.1 Change-Id: If0a5082adb735a73efd793868b3a55bc7d694cbe Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Support runtime functions evaluation by index through QQmlEngineAndrei Golubev2021-02-124-0/+58
| | | | | | | | | | | Add execution function that can evaluate runtime functions available in the compilation unit. Private API for now as it's unclear what would be a comprehensive solution to support all existing use cases Task-number: QTBUG-84368 Task-number: QTBUG-91039 Change-Id: Icf755b53484587d7983eaae4821c1aa0111d5c05 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Transform JSCallData args setting into a functionAndrei Golubev2021-02-124-22/+85
| | | | | | Change-Id: I4154a0b5c7115375292794e0564d2f3657e6b4dd Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Unregister value types when tearing down QML typesUlf Hermann2021-02-1218-210/+154
| | | | | | | | | Move the value type registry into QQmlMetaTypeData. This way we can conveniently drop the relevant entries when unregistering a type. Fixes: QTBUG-86946 Change-Id: Id024a34a8b2b622fd9417fc0e52864b43c66cc01 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use functions as signal handlers when accessing parametersUlf Hermann2021-02-126-11/+11
| | | | | | | | | Injected signal handlers are bad practice because they aren't declared. Pick-to: 6.1 Task-number: QTBUG-89943 Change-Id: I3a691f68342a199bd63034637aa7ed438e3a037b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Add missing \inmodule commandNico Vertriest2021-02-122-0/+3
| | | | | | Task-number: QTBUG-90439 Change-Id: I0e29e2ee090d5aa4ae40bcca4bd5fa14f87d9c0c Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
* Doc: Fix CI warnings qtdeclarativeNico Vertriest2021-02-121-10/+10
| | | | | | | | Fix errors with \fn and hidden friend functions Task-number: QTBUG-90439 Change-Id: I1de021c953efdd397de4bb25cbe3180175265174 Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
* Doc: Avoid unqualified lookup in the signals documentationUlf Hermann2021-02-121-2/+2
| | | | | | Pick-to: 6.1 Change-Id: Ibcb20311c7e5a56038c738da77d9dfcc9464bce4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Warn about variables being used before their declarationUlf Hermann2021-02-114-13/+35
| | | | | | | | | | | | | | | | | | This collides with injected signal parameters. qmlcachegen cannot tell those cases apart. [ChangeLog][QML][Important Behavior Changes] QML warns about JavaScript variables being used before their declaration now. This is almost always a mistake. It is particularly dangerous in the presence of injected signal parameters because qmlcachegen cannot identify a name collision between an injected signal parameter and a variable being used before its declaration. It therefore miscompiles such code. You can turn off the deprecation warning using the "qt.qml.compiler" logging category. Pick-to: 6.1 Task-number: QTBUG-89943 Change-Id: I8a9424ca8c6edd562402fe5c560ba7e8344b5585 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QHashedString(Ref): Use QStringView internallyFabian Kosmale2021-02-113-99/+28
| | | | | | | | | | | | | | | We cannot store a QStringView internally, as that would increase the size of our objects (QHashedString(Ref) does not support strings with sizes that do not fit into 32bit, thus it can store the hash and the size in one 64 bit block). What we can however do is to construct a QStringView on demand (which is cheap), and use its methods. The benefits are twofold: We get rid of some accidental complexity in qtdeclarative; and the code in QStringView is actually SIMD optimized. Change-Id: I2445a2d5a16b253f4971d7f3be0e1b274326eacb Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Restore String size assertFabian Kosmale2021-02-101-0/+2
| | | | | | | | | Just like all of the other datastructures in qv4compileddata, changing the size of String would require an inrcement of QV4_DATA_STRUCTURE_VERSION. Change-Id: I462d04204255946d309d245bc20b044ba9d222d7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QV4::Lookup: update comment about gc assumptionFabian Kosmale2021-02-101-0/+1
| | | | | Change-Id: I13304631a9870874fb130cd9e6598065fc952a71 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlPropertyPrivate: Remove documentation about flags parameterFabian Kosmale2021-02-101-3/+0
| | | | | | | The parameter is gone since 3bc239a0f16fb93f84def55a5980ef8561e7a7b4 Change-Id: Iae411b61f27efd60b489dbc219ef0ad07ad19938 Reviewed-by: Ulf Hermann <ulf.hermann@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>
* Support and prefer QML_IMPORT_PATH over QML2_IMPORT_PATHUlf Hermann2021-02-105-36/+49
| | | | | | | | | | 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-093-5/+5
| | | | | | | | | 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>
* Doc: Update type registration flowchartUlf Hermann2021-02-093-0/+3
| | | | | | | | | You're not supposed to call the registration functions manually. Pick-to: 6.1 Fixes: QTBUG-90718 Change-Id: I829800132484dea670657ed1679357fe58d0ddf9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Reimplement Math.hypot() using QHypotHelperEdward Welbourne2021-02-091-21/+6
| | | | | | | | As part of adding qHypot() in qtbase, we now have a robust efficient implementation of arbitrarily-many-parameter hypot(), so reuse it. Change-Id: Iafd0eee84f3271c37003431a5f2b1a62d7ef6f86 Reviewed-by: Ulf Hermann <ulf.hermann@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>
* qjsengine: Clarify to/fromScriptValue documentationMaximilian Goldstein2021-02-081-0/+2
| | | | | | Fixes: QTBUG-89956 Change-Id: I96439433b1f172e933c6c56daae639be7e18b931 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-0510-115/+385
| | | | | | | | | | 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>
* QSequentialAnimationGroupJob: Protect against self-deletionUlf Hermann2021-02-052-9/+9
| | | | | | | | | | | setCurrentAnimation() can indirectly delete the animation group job itself by invoking the animation controller. Use the RETURN_IF_DELETED mechanism to avoid the resulting dangling pointers. Task-number: QTBUG-90401 Pick-to: 6.1 6.0 5.15 5.12 Change-Id: Ibd0ad21e8d3af4760604c3ff37dc46101d5f49ad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlBind: support bindable propertiesFabian Kosmale2021-02-031-9/+40
| | | | | | | | | | | | This patch ensures that the QML Binding element can also save and restore C++ bindings. Should QQuickItem's x and y property be ported to the new property system, we'd need new test cases to verify that "old-style" bindings are still handled correctly. This task is however left for the change porting the properties. Task-number: QTBUG-90493 Change-Id: I506ffa1060ff32a7d722214e5ccd469bdaa61ff8 Reviewed-by: Ulf Hermann <ulf.hermann@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>
* Fix Math.round edge-caseAllan Sandfeld Jensen2021-02-021-3/+6
| | | | | | | | | Round 0.49999999999999994 correctly Task-number: QTBUG-90444 Change-Id: I0e8a19fb52540c6e976308089a782f1f472bc77f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add 'MANUAL_MOC_JSON_FILES' support by 'qt6_qml_type_registration'Alexey Edelev2021-02-021-1/+6
| | | | | | | | | | | Pass the 'qt6_qml_type_registration' function's 'MANUAL_MOC_JSON_FILES' argument to 'qt6_extract_metatypes', if specified. Align the 'qmltyperegistrar' test to modifications in the 'qt_manual_moc' and 'qt6_qml_type_registration' functions. Task-number: QTBUG-84906 Change-Id: I6b23526e1cc4633f55536871cbb7bc6d891f1dea Reviewed-by: Fabian Kosmale <fabian.kosmale@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>
* Fix cmake dependencies around qmltypes filesUlf Hermann2021-02-011-1/+8
| | | | | | | | | | | | qmltypes files are generated by qmltyperegistrar, and conditionally consumed by qmlcachegen. In turn, the C++ files generated by qmlcachegen must not declare any moc'able constructs as that would be a circular dependency via the metatypes.json files. Codify this condition as a SKIP_AUTOGEN property on the generated C++ files. Change-Id: Ied2ca6ad202dd20039bca9823ef1de4fffcf64d5 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> 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>
* Doc: Describe QML_FOREIGN in "Defining QML Types from C++"Ulf Hermann2021-01-291-0/+26
| | | | | | | | Fixes: QTBUG-83852 Change-Id: I8dd5fa6887ad607fe91ac658efa51152c46df36e Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* V4: Store instruction pointer before CmpInUlf Hermann2021-01-272-0/+2
| | | | | | | | The "in" operator may throw an exception. Change-Id: I7d0b6e2212ac6ec237fbf14719349f8e23810028 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> 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>
* QAnimationGroupJob: Don't call virtual functions from dtorUlf Hermann2021-01-222-23/+42
| | | | | | | | | | | | The subclasses are already dead at that point. We don't need to notify them anymore. Rather, refactor the code so that we can clean up QAnimationGroupJob itself without virtual calls. Task-number: QTBUG-90401 Pick-to: 5.12 5.15 6.0 Change-Id: I6917bf299ceb1383b9d29687e5bf53ae36803ecf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@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>
* QJSEngine: Add a function to throw a pre-generated error objectUlf Hermann2021-01-222-0/+15
| | | | | | | | | | | | | | | It makes little sense that you can construct an error object but not throw it. The test was definitely meant to actually throw the error object, not return it. [ChangeLog][QtQml] QJSEngine has gained an additional overload to the throwError() method, with the effect that calling throwError() with a character literal as argument is now ambiguous. You should explicitly construct a QString instead. Change-Id: I90c6c9edf10509daa142a86581d6a3f7ff45af2c Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> 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>
* Use new QObjectPrivate connection mechanism in dynamic connectionsAndrei Golubev2021-01-211-2/+18
| | | | | | | | | | | Old API assumes sender == receiver, which results in wrong handling of connections when receiver is deleted: connection is not removed or notified elsehow as it's not really tied to a valid receiver Task-number: QTBUG-86368 Pick-to: 5.15 6.0 Change-Id: I0f3115f1b0f26cf353752ba2b8fd88e0f3bdd388 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Change section about writing a qmltypes fileUlf Hermann2021-01-201-102/+8
| | | | | | | | | | | You should not write qmltypes files manually. We only document their existence and that you should add them to manually written qmldir files now. Change-Id: I434398656179806c3e57724324aba38738384e1d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>