Commit Graph

3671 Commits

Author SHA1 Message Date
Ulf Hermann f5514e682b QtQml: Fix and test edge cases of QQmlFile's local file detection
URLs with two slashes after the colon are generally _not_ local as they
contain an authority. However, file URLs with two slashes are
interpreted as "special" paths by QUrl::toLocalFile(). Therefore, we
accept them.

URLs without slashes after the colon can be local files. They denote
relative paths or special android resources then.

Pick-to: 6.2 6.3
Fixes: QTBUG-102944
Change-Id: Iaab3d7501b631e88ee8c1d93f1de8149ba60a5c4
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-31 12:54:49 +02:00
Ulf Hermann 6ff6c088c2 QmlCompiler: Add support for LoadElement on strings
In JavaScript the [] operator on strings returns a string. QString's
operator[] returns a QChar, but we can easily create a string from that.

Fixes: QTBUG-103371
Change-Id: Id5c960f00ecc7a5dfe30ccbcaac3ffb2a30308b9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-24 15:44:16 +02:00
Ulf Hermann a75ddda71b QmlCompiler: Implement LoadElement for value type lists
Instead of the storedType hack in the type resolver, properly declare
the type LoadElement can return: A merge of undefined and the actual
type. This way we can choose the best concrete type to use for this
independently (and optimize it later).

Task-number: QTBUG-103529
Change-Id: I17b1f835f6a893ec843a90491e92f72ecb2e87fe
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-24 15:44:16 +02:00
Maximilian Goldstein 3d8702378b tst_qmllint: Write clearer descriptions when unexpected output is found
Previously we just crammed it all into one line.
This made debugging really painful. You either had to properly cut out
the source code, remove all the additional quoting and reformat it or
run qmllint manually to get proper formatted output.

This way you can actually debug these issues without resorting to any
external tools.

Change-Id: Iafdaaaa0ef7b96e70057b9b637b7c8f051d9e43a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-24 15:44:16 +02:00
Ulf Hermann 4d71091a19 qmlcompiler: Evaluate pragma ComponentBehavior
If components are bound we can assume the IDs of outer components are
reachable.

Fixes: QTBUG-102806
Fixes: QTBUG-101012
Change-Id: Ia26d3963d6c2fb9698debb12f9c655c5522f81ea
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-24 15:44:16 +02:00
Andrei Golubev ff0b9ec6bf Revise QQmlProxyMetaObject and extension chain creation
Clone the full-ish meta object hierarchy when dealing with extensions:
that way we guarantee that shadowing works correctly both ways -
extension properties can shadow type properties AND type properties
can shadow extension properties (the latter happens when extension
belongs to a base type). This was impossible before since we would
always put extension proxies on top of the meta object chain,
regardless of where in the chain extensions are located. Consider:
"C -> B + ExtensionB -> A + ExtensionA" is interpreted as
(old) ExtensionB -> ExtensionA -> C -> B -> A
      ^^^^^^^^^^^^^^^^^^^^^^^^    ^^^^^^^^^^^
        cloned meta objects     static meta objects

(new) C -> ExtensionB -> B -> ExtensionA -> A -> C -> B -> A
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^    ^^^^^^^^^^^
               cloned meta objects             static meta objects

One can notice that we now clone _more_ meta objects: this is to
be able to to create a chain with correctly ordered properties

Unify the proxy data creation under QQmlMetaType::proxyData()

Update QQmlProxyMetaObject which now has to deal with different types
of proxies: not only extensions but also "cloned" self. CustomCall
metaCall() of QQmlProxyMetaObject is also adjusted to ignore
non-extensions

Change-Id: I40e1547a9c05a8504ab98bc06a6bc412a2460783
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-24 10:30:48 +02:00
Andrei Golubev c02dd17a4f Support extension property revisions
Previously the extension's property revision would make
the property unusable since extensions would've been skipped
from property cache construction w.r.t. revisions

This is due to the meta object cloning that we do for
extension types (since we put the cloned meta object on top
of the meta object hierarchy for the QQmlProxyMetaObject).
Once cloned, the meta object has no associated QQmlType
anymore and we need one to deal with revisions. Overcome this
by registering the cloned meta object in the QQmlMetaTypeData

From now on, the cloned extension meta object has an
associated QQmlType, which is the *extended* type, NOT the
*extension* type

Change-Id: I4a6a4380278b80e49e1b9874dd458183667e5cb5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-24 10:30:44 +02:00
Ulf Hermann 7fa03450cf QML: Add an option to bind components to files
If a component is bound to a file context, we can be sure that the IDs
present in the same file will be accessible to bindings and functions
inside the component. We will need this to allow such bindings to be
compiled to C++.

[ChangeLog][QtQml] You can now bind components to a file scope. This way
you can make sure IDs in the file are accessible to the components.

Task-number: QTBUG-101012
Task-number: QTBUG-102806
Change-Id: I290a61752b4b02e13f0bb0213ba3f871bdb95260
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-23 12:50:02 +02:00
Andrei Golubev cfbc5ecf2a QML: Correctly detect extended types
Introduce a compile-time procedure to distinguish types without
extensions but with base type extensions from types with direct
extensions. Previously, we would have treated both cases the
same due to the C++ mechanism employed to mark a type as
extension-containing

As a drive by, make QQmlMetaType::clone() use class name of the
extension when we clone the extension

[ChangeLog][Important Behavior Changes] A derived type is no longer
considered to be extended itself when only its base type is extended.
Instead, the extension only exists on the base type.

Change-Id: I74092a5f88cad09c1e07626ae90bb986db0da73d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-23 12:50:02 +02:00
Sami Shalayel 69cd8c2779 qmlcompiler: Add qualified name to QQmlJSScope
Added moduleName and qualifiedName to QQmlJSScope. Those
properties are written in the scopes after they were
loaded by readQmlDir.

Fixes: QTBUG-103299
Change-Id: I3b2c68c43c3bf0ac6cf801b0e54cf4b412b4d4e5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-05-23 12:50:02 +02:00
Maximilian Goldstein 827193b3a1 qqmljsimportvisitor: Fix assert being hit on empty block bindings
We previously hit an assert / crashed if we saw an empty script binding.

Fixes: QTBUG-103707
Change-Id: I117d984a7d315ecf860d2ada5568637d154ae083
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-05-19 22:30:23 +02:00
Ulf Hermann 4a10e1d84a QmlCompiler: Detect non-integral values when accessing QQmlListProperty
Pick-to: 6.2 6.3
Fixes: QTBUG-103560
Change-Id: Ifcc73baf7f79e30f6e83ff3e500dd39f95790bfe
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2022-05-19 22:30:23 +02:00
Ulf Hermann 70da741404 QmlCompiler: Do not coerce value type lists to QQmlListProperty
QQmlListProperty is only for object lists. Object lists are the only
thing we can use in LoadElement for now.

Fixes: QTBUG-103529
Change-Id: Ia120addcfc0afcbf1815d1bd9671f20df8334744
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-05-18 19:40:58 +02:00
Maximilian Goldstein 8db0402e72 qmllint: Properly warn about missing required properties in delegates
Previously we would often suggest to add an id to the view containing
the delegate so you could access the model that way which is very
misleading and might be especially bad as an automatic suggestion.

This change now recommends that the user adds a required property,
although we currently lack the logic to properly insert one for the user.

Fixes: QTBUG-103101
Change-Id: I4cd858ff6617d12b9abf070f524dc626d699e4f1
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-17 16:38:17 +02:00
Ivan Solovev c9013be2d9 tst_qqmlqt: fix TimeZoneSwitch logic
The TimeZoneSwitch class was setting the doChangeZone flag incorrectly,
so it was actually trying to change the zone only for "localtime".
This patch fixes the issue.

With this fix applied, the test started failing on some OS that fail
to change local timezone, so skip such input data for these
configurations.

Fixes: QTBUG-100014
Pick-to: 6.3 6.2
Change-Id: If39a15fe1008211a940174fdc3aa5209df34c115
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-17 16:38:17 +02:00
Maximilian Goldstein 2ebee301fd Reimplement PropertyPass to evaluate bindings
This change reimplements the PropertyPass to be based on bindings
rather than on just iterating over elements. This is a lot less
cost intensive than iterating over all properties regardless of
whether they are actually used. You may still achieve the same
thing with the more flexible element pass, just with the benefit
that you can choose what properties you want to iterate over
instead of iterating over all of them.

To demonstrate the passes usefulness the existing attached property
warnings are ported to use the binding pass and can now also warn
when an attached property is read or written in a context where
it's not supposed to be used.

Fixes: QTBUG-102860
Fixes: QTBUG-102418
Task-number: QTBUG-102859
Change-Id: Iea87a1b05b954429b8bf00fd27b60487940af679
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-16 18:22:45 +02:00
Maximilian Goldstein 78483744b4 QmlLintQuickPlugin: Warn about various SwipeDelegate issues
Implements anchor related and back/left/behind combination warnings.

Also adds a quality-of-life improvement in tst_qmllint where we print the
line when an expected message is missing.

Task-number: QTBUG-102277
Task-number: QTBUG-102859
Change-Id: I56068c75e3c6187845b079a6689debefa363a5e4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-12 17:36:12 +02:00
Andrei Golubev 5cd59bff0c Support querying indirect extensions for a given object
Introduce a private version of qmlExtendedObject() that returns an
index-based extension (where 0 represents an extension on the leaf type
and N represents a (N - 1)th base type's extension)

Teach QQmlProxyMetaObject to distinguish different extension proxies.
Its custom metaCall can now query up to 128 extensions (should be enough
for the user needs)

Change-Id: I5520a1e84501f1f9fe6a8e77d8269009a12c255c
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-12 17:36:12 +02:00
Ulf Hermann d0c7c7234c Generalize role selection mechanism from QQuickComboBox
We can have QQmlDelegateModel pick specific roles from model items. That
can easily be done for variant maps, variant hashes, objects and
gadgets. We would like to do it for anything that has a
QMetaAssociation, but as we cannot get to the original type at that
place, it's currently not possible.

The special case about variant maps with exactly one item in variant
lists is clearly insane and therefore not included in the
generalization.

This requires some cleanup in the QQmlGadgetPointerWrapper. Passing the
wrapper itself to QMetaProperty::read() has always been a rather obscure
way of reading from the gadget.

Pick-to: 6.3
Fixes: QTBUG-102983
Change-Id: I84ecef980783e7137aa4d77070ddce47b6ead260
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-11 16:25:16 +02:00
Ulf Hermann 36ebee4e69 QML: Port QV4::CompiledData::Binding to new special integer bitfield
Pick-to: 5.15 6.2 6.3
Task-number: QTBUG-99545
Change-Id: I9f8bc5fa45c61f77ee95b055a3d8de001da8f8c5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-11 12:56:22 +02:00
Ulf Hermann cf9c0f0180 Avoid memory leaks in QQuickListView and tst_qqmlinstantiator
Pick-to: 6.2 6.3
Change-Id: Ieceffedb082e893b54bcda99076df3ccdeff6010
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-05-11 10:06:38 +02:00
Andrei Golubev b13a66f1c8 Distinguish extensions from extension namespaces in QmlCompiler library
QML_{NAMESPACE_}EXTENDED and QML_EXTENDED_NAMESPACE are supposed to
behave differently when it comes to visibility of properties, methods,
etc. Thus, make it so by actually using different class infos and
updating QQmlJSScope. Use a HasExtensionNamespace flag to differentiate
between extension and extension namespace (whenever one of them is set)

Update the internal search routine that traverses the base types and
extensions of the given scope

Change-Id: Ifafbb22f831f5b128e431a3e65c514ffdf65eb73
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-09 16:50:07 +02:00
Andrei Golubev a287e862d4 Fix extension lookup in QQmlJSScope
Do not go over extension's base types since this is not how the engine
logic work. Instead, only assess the direct extension type when
traversing the base type hierarchy. The special cases are value types
which still need base type extension traversal (e.g. due to Number
and NumberPrototype extensions on primitives) and QObject type itself
(we expect to see ObjectPrototype properties / methods of it)

Pick-to: 6.3 6.2
Change-Id: I92ba979202b33f16e1a7b948d4f1e79df37f2669
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-09 16:50:07 +02:00
Ulf Hermann 2bed3d5f0f V4 Engine: Don't try to convert JS functions to other types
When converting a JS value to a variant, if we notice that we get a
QJSValue again, there is no point in trying to convert it further. We'll
just run into infinite recursion.

Pick-to: 6.3
Fixes: QTBUG-102545
Change-Id: I0a40e21287e5460e5e214101aabe8d2b4bf0afad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-09 11:59:49 +02:00
Andreas Buhr 5049dcb268 Skip crashing tst_qqmlbinding::delayed() on Android
Pick-to: 6.2 6.3
Task-number: QTBUG-103310
Task-number: QTBUG-101865
Change-Id: I22454487f0bbb7e124a1e870ff936e7513748af9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-07 09:45:55 +02:00
Andrei Golubev ffe017b92c tst_qqmljsscope: Fix test module importing
The name of the module's folder should match the URI and
application binary dir should be provided as an extra import
path for the module to be discoverable

Change-Id: I00d67593d18dc86c0929f8a64b2c165221a4758a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-04 22:34:15 +02:00
Andrei Golubev 6390cc5d24 QQmlJSImportVisitor: do not register group { ... } as an object scope
Grouped properties do not bind to a default property and they are not
object definition scopes. Fix the subtle issue where we'd do the
opposite for `group { ... }` syntax

Submit the tst_qqmljsscope changes that made the issue visible

Pick-to: 6.3
Change-Id: I314b19d5cad62f70146d228e5402c9fc73b309ad
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-04 22:34:15 +02:00
Andrei Golubev 218eb5f571 QQmlProxyMetaObject: Ignore properties/methods of non-creatable proxies
Qt/QML allows marking a type with QML_EXTENDED_NAMESPACE(Type) where
Type is a Q_OBJECT. In this case, we have a Type-specific meta
object but do not have an extension function to create the object of
that Type with, causing us a subtle runtime crash. The crash in fact
happens when we attempt to access a shadowed property through the
extension object (which surely fails since there's no extension object)

Fix this by excluding properties and methods when cloning the metaobject
for the proxy if we know that the proxy cannot be created. This somewhat
matches what the documentation says about QML_EXTENDED_NAMESPACE:
When we have a Q_OBJECT/Q_GADGET, methods and properties of that are not
exposed

As a drive by, add the same check to the QQmlMetaType::proxyData().
While untested, this seems logical since the proxy data assumes valid
creation function in this case as well

Fixes: QTBUG-103081
Change-Id: I63c6e535d4df5169e0279eb2f588593f43a70640
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-04 22:34:15 +02:00
Andrei Golubev 74bcf29064 Add extra extension tests to tst_qqmllanguage
a) Test-document the behavior when we have QML_EXTENDED() with a Type
which itself does not provide any properties but instead has a base type
that does. In this case, we won't consider base type properties from
extension in the meta call resolution, using the non-extended properties
instead

b) Test what happens in various cases of property existing only in
extension type

Change-Id: I5340e8d6606b2f170e9766716871c5a6a8cba948
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-04 09:28:22 +02:00
Maximilian Goldstein ee30dd815e qmllint: Warn about invalid anchor combinations across components
Previously we only warned when a component we were linting contained all
of the anchor properties causing a conflict. Now we also warn if the
combination is created across multiple components or files.

Also makes QQmlJSMetaPropertyBinding record undefined literals as they are
needed to tell whether a property has been reset somewhere in a type.

Task-number: QTBUG-102859
Change-Id: I04012848d0526cce6aea34036c6b2e0daf79cf9d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-03 15:25:11 +02:00
Andreas Buhr bdbab58de7 Skip crashing test in tst_qmlcppcodegen on Android
tst_QmlCppCodegen::scopeObjectDestruction() crashes on Android.
Skip this test for now.

Pick-to: 6.2 6.3
Task-number: QTBUG-103044
Task-number: QTBUG-101865
Change-Id: I1d6291decf946b954bffc2378255c209126106fd
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-03 15:25:11 +02:00
Andrei Golubev 2299031225 qmltc: Move alias compilation to qqmltccompiler
Introduce an alias resolution procedure to query the origin
property and its owner for a given alias

Add alias compilation to the "proper" qmltc code and remove
the equivalent one from the prototype

Change-Id: I55bc1e3e6206b4cfce259526d1bc2813e8ea7cfb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-03 15:25:11 +02:00
Ulf Hermann 9dc3b0a06c tst_qqmltranslationservice: Fix order of UI languages
QLocale reversed the order of languages returned from uiLanguages()
recently. Adapt the test to this change.

Fixes: QTBUG-103026
Change-Id: I471351494bd56e48d1cf4bee3f6f27a786c5b107
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-03 01:01:30 +02:00
Ulf Hermann 3a4b6b9ba2 tst_qqmldebugtranslationservice: Avoid memory leaks
Change-Id: Ib2b7a70fa015a298362cc56bb3da2819aeedd33c
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-05-02 21:58:59 +02:00
Sona Kurazyan 2c9c1590e6 Replace uses of deprecated _qs with _s/QStringLiteral
Task-number: QTBUG-101408
Change-Id: Ic925751b73f52d8fa5add5cacc52d6dd6ea2dc27
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-29 09:47:43 +02:00
Ivan Solovev ecc87ea077 Android: enable tst_qqmlenginedebugservice
The test was failing because it was using QML code that was embedded
directly in the test, so the dependencies were not detected and
deployed.

This patch moves QML code into separate files, so that qmlimportscanner
could provide all the necessary dependencies.

Fixes: QTBUG-100166
Pick-to: 6.3 6.2
Change-Id: I5581de9a4573204722ad60eaceae8d05a491eb13
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-04-29 09:47:43 +02:00
Ivan Solovev 0f9abd63b9 QQmlDataTest: fix dataDirectoryUrl generation for paths in qrc
When the data directory is located in qrc (like on Android), the data
directory url was generated incorrectly, missing the last '/'.
As a result QQmlDataTest::dataDirectoryUrl().resolved("something") call
was providing incorrect results.
This patch fixes it, which allows to unblacklist
tst_qqmlqt::resolvedUrl() for Android.

Task-number: QTBUG-100014
Pick-to: 6.3 6.2
Change-Id: Id336a698b493edaa6e2ab7d36efbbef1f5acd1d6
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-29 09:47:43 +02:00
Ulf Hermann c86b340f47 Demote the deferred property warnings to qCInfo
The most important places where we want to avoid early execution of
deferred bindings are checked with QtQuickControls' tst_sanity. The
whole thing is private API, so users cannot run into this themselves.
Conversely, if users trigger early execution of deferred bindings, that
may be on purpose.

Fixes: QTBUG-98964
Change-Id: I81e5391ff1059137fa8eba8cdd39f58262f22252
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-04-29 09:47:43 +02:00
Ulf Hermann c751647430 QmlCompiler: Add test case for descriptive name of invalid type
Task-number: QTBUG-102147
Fixes: QTBUG-102968
Change-Id: Ifa6ab7490ed914f08da19b6928aeb1b105c448e5
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-28 22:50:25 +00:00
Alexandru Croitor ba67601ad3 Skip flaky hanging test on macOS in CI
The flaky test hangs and is eventually registered as a crash in
the CI.

Task-number: QTBUG-101678
Task-number: QTBUG-101972
Task-number: QTBUG-102984
Change-Id: Id12b0c7032d31c97b24b6cf88fcbf2f28be1c293
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-28 21:00:44 +02:00
Maximilian Goldstein 7dd6fbb51a QmlLintQuickPlugin: Remove redundant anchors null warning
Previously we warned when an anchor was null again after already
displaying a generic warning about a type mismatch. This is redundant,
so let's stick with the generic one.

Change-Id: I8f43d279b712d728dc154f48286b8d5c0dac9976
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-28 15:55:03 +02:00
Maximilian Goldstein 4b330fa07b qqmljsscope: Add static prettyName() function
Implements QQmlJSScope::prettyName() which will strip off any internal
prefixes (such as $internal$ and $anonymous$) and also return some more
user recognizable type names (i.e. null instead of std::nullptr_t).

Change-Id: I085b51ea9fe6b348fb24efa93726c47b79846a8b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-28 15:39:52 +02:00
Andrei Golubev ccf996fbe4 tst_qqmljsscope: Address unsigned value to 0 comparison warning
As we deal with unsigned integer indices, there's no point in testing
them for >= 0 as this is always true. Apparently it is a -Wtype-limits
warning for some compilers

Change-Id: Ic5d633c2cc73f811f127f16f4d769d154364ccd0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-28 09:43:36 +02:00
Andrei Golubev e98faf1df4 qmltc: Support setting Gradient property of Rectangle
Fixes: QTBUG-102560
Pick-to: 6.3
Change-Id: I7c339d2807a723f38e18e06b944362449d89ad7a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-28 09:43:36 +02:00
Andrei Golubev aafc094a55 qmlcompiler: Add absolute runtime function indices
We can transition to absolute indices (within the compilation unit)
from the relative indices we already have in each method and script
binding. Together with absolute indices, we also need to acknowledge
nested closures that some AST elements might have and so also store
nested runtime function indices along with the absolute ones

Absolute runtime function indices (and the nested ones) map to the
indices we store and use within the compilation unit at run time,
which are used to dispatch to correct JavaScript call during e.g.
binding evaluation - see QQmlEnginePrivate::executeRuntimeFunction()

Change-Id: Ieec58fbc36563511bd9763e358cda46c67757fa9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-28 09:43:36 +02:00
Ulf Hermann 4a6cabf3eb QQmlOpenMetaObject: Clarify signal numbering
When creating a property and a signal, the indices can be different.

Task-number: QTBUG-102454
Change-Id: Id459d6476a6b1dc6c3d524ed3fe34d8d5535a3af
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-28 07:43:36 +00:00
Ulf Hermann 871024cdce QmlCompiler: Fix licenses in test files
Those are not commercial-only anymore.

Change-Id: I4ebb6fa4b8295b9e5cbb901ab39e30df6e0c85ce
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-28 09:43:36 +02:00
Ulf Hermann 25eca6b7cf Fix crash in QQmlObjectCreator::populateInstance
If we cannot create the attached properties object, we need to generate
an error and return early. The attached properties are unavailable then.

Pick-to: 6.2 6.3
Fixes: QTBUG-101401
Change-Id: I92539ba577b435675f812c4a2bdbbbfd1de65ecf
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-27 15:29:25 +02:00
Ulf Hermann 95837745e4 QQmlTypeCompiler: Find implicit components for inline component roots
Pick-to: 6.2 6.3
Fixes: QTBUG-102719
Change-Id: Ia6654f617d9d0922c94a5e204f9559e95c529641
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-27 15:29:25 +02:00
Maximilian Goldstein 3265013769 QmlLintQuickPlugin: Warn about attached types used in wrong elements
The engine will warn when various attached types are used in elements
where they are not supported.

This patch replicates this behavior in qmllint with the exception that
we cannot handle them being used in bindings right now.

Task-number: QTBUG-102277
Task-number: QTBUG-102859
Change-Id: Ic41c9338d8625c5185dbd658cc8987f3c00f18c3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-04-27 15:29:24 +02:00
Maximilian Goldstein 4b3e99b9a2 QmlLintQuickPlugin: Warn about disallowed positioning properties
When using Grid and Flow, children are not supposed to use anchors or
the x and y property. The same applies to the children of Layouts which
in addition should not set width or height.

This change adds the warnings when these properties are set improperly.

It also adds tests for the existing warning about the children
of Layout not being allowed to use anchors.

Task-number: QTBUG-102277
Task-number: QTBUG-102859
Change-Id: I83c553569cdba90c8841802090d4ef534583ecb8
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-04-27 15:29:24 +02:00
Ivan Solovev 0eb538b9b9 Android: enable tst_qquickfolderlistmodel::basicProperties()
The test was skipped on Android because it was trying to read the
contents of default directory for FolderListModel, which requires
special access rights on Android. The test passed when started via
androidtestrunner, but failed when launching the APK directly.

Generally this test does not need to get the number of files in the
default directory. It just needs to know that its processing is
finished, so that we can switch to other directory, and do all the
checks there.
So this patch waits for folderChanged() signal instead of verifying
that the number of elements in default directory is > 0.

Also skip the parentFolder property check on Android, because the
qrc path is not resolved to be a local directory, to parentFolder
always returns a default-constructed QUrl.

Fixes: QTBUG-77335
Pick-to: 6.3 6.2
Change-Id: I95510ebad724db42890414b810b2350be0d8dcac
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-04-27 15:29:24 +02:00
Ivan Solovev bfcaec81a8 Android: fix tst_QQuickFolderListModel
Fix couple of previously blacklisted tests:

- tst_qquickfolderlistmodel::nameFilters()
  This test had a problem with permissions to read the contents of
  default directory. This is not an issue when running with the
  latest androidtestrunner, but can be a problem when directly
  launching the test's APK. To avoid inconsistency, this patch
  sets the default dir to resources root dir, because it's always
  readable.

- tst_qquickfolderlistmodel::introspectQrc()
  This test had a problem with incorrectly generated qrc file.
  This test has two qrc files - one for all test data, as it's
  usually done for Android, and another one - to test that custom
  prefixes work properly. The latter resource file had an invalid
  alias (which included the "data" dir).
  The reason for the error was that the same data file was already
  process when the global resources qrc file was generated.
  At that time the alias prefix was set, and then reused.
  To fix it we need to explicitly reset the QT_RESOURCE_ALIAS
  property before generating the second qrc file.

Fixes: QTBUG-100016
Pick-to: 6.3 6.2
Change-Id: I04896c3f8d7e845a087a74f841fdad54cb6471f9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-04-27 15:29:24 +02:00
Andrei Golubev b4d5b64359 Make QQmlEngine resolve closures when executing runtime functions
QML can create a function which holds a closure in the cases like:

onSignal: function() { ... }

If the left-hand side is a signal handler (or similar), we want to
execute the *inner* function when a signal is called, not the outer
one. However, under certain conditions (e.g. we use `this`), the
outer function must also be called beforehand to correctly setup the
calling scope for the inner function

Thus, make the QQmlEnginePrivate::executeRuntimeFunction() do that:
always call an outer function first and then the inner one if present.
This creates an overhead when dealing with certain signal handlers but
we could optimize it later if needed

Note that the case `property var prop: function() { return 42; }` where
a property contains a callable function is no longer supported by the
executeRuntimeFunction() routine (we always call the inner code now).
This is fine since qmltc (the main beneficiary of the routine) does not
rely on this functionality when dealing with property bindings

Given the change, qmltc can be simplified to only work with absolute
function indices, ignoring the nesting problem altogether

Change-Id: I61f61587b6fe700cb695b3b7a213d9cfab0eb746
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-27 15:29:24 +02:00
Andreas Buhr 44e83fc238 Fix tst_QQmlXmlListModel::threading() on Android
tst_QQmlXmlListModel::threading() tried to create some temporary
files in a qrc: path on Android. This patch changes it to use
a QTemporaryDirectory for it.

Pick-to: 6.2 6.3
Task-number: QTBUG-101865
Change-Id: I66b44344af822edfe86b0007ae56a65d5da46365
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-04-26 21:38:02 +02:00
Andreas Buhr fcb38e2ff8 Blacklist tst_qmltc::listView on Android
tst_qmltc_diskcache keeps appearing in test failures.
It is flaky. And it seems to be a special kind of flakyness: On some
days it always fails, on other days it never fails. It does not seem
to be random.

Pick-to: 6.2 6.3
Task-number: QTBUG-101342
Task-number: QTBUG-101865
Change-Id: Ia6716d38a10f348199d3582be8453d52f331a8b1
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-04-26 16:39:08 +02:00
Andreas Buhr 9bbc43fbd1 Fix tst_QQmlXmlListModel::source() on Android
tst_QQmlXmlListModel::source() assumed that local files are loaded
immediately and others later.
This is not true for files in the qrc: system. They are not local
files. But still, they are loaded immediately. This patch
fixes the test.

Pick-to: 6.2 6.3
Task-number: QTBUG-101865
Change-Id: I13a449cefe12135d4c6cd7687c80f41b7333349e
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-04-26 16:39:08 +02:00
Andreas Buhr 8976a55dac Fix tst_qqmltranslation on Android
tst_qqmltranslation::translation(qrc) had a problem with incorrectly
generated qrc file. This test has two qrc files - one for all test data,
as it's usually done for Android, and another one - to test that custom
prefixes work properly. The latter resource file had an invalid
alias (which included the "data" dir).
The reason for the error was that the same data file was already
process when the global resources qrc file was generated.
At that time the alias prefix was set, and then reused.
To fix it we need to explicitly reset the QT_RESOURCE_ALIAS
property before generating the second qrc file.

Pick-to: 6.2 6.3
Task-number: QTBUG-101865
Change-Id: Ibd7e2a41ffffc3601db9722d155932a3cc9a9b54
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-04-26 16:39:08 +02:00
Maximilian Goldstein 6186dab608 QmlLintQuickPlugin: Warn about invalid anchors combinations
Includes more anchors related warnings that get usually get
shown at runtime.

Task-number: QTBUG-96737
Change-Id: I2a72d7fc9b23072f85d20fff558e39311e749e4c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-04-26 12:36:58 +02:00
Andrei Golubev 3340bdf24f qmlcompiler: Add relative index for scripts and JS functions
Store relative (to scope) index for every Script binding and JavaScript
function into the corresponding data structure within QQmlJSScope. We
need this at a later phase in qmltc when code generating JavaScript
calls into the engine

For now, ignore the logic that converts the relative indices stored into
the indices pointing to the runtime function table

While testing the addition, observe missing cases where we do not record
bindings as such and fix that

Change-Id: I85030b7937c97f83183f88ae242af3a5f223443c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-26 09:04:51 +02:00
Andreas Buhr 9eb8f202b6 Fix tst_qqmlimport on Android
This patch moves a code snippet from a string into its own file,
so qmlimportscanner can see it and pull its dependencies.
Second, this patch enables removal of '\r' in an expected log
message, as this seems required now.

Pick-to: 6.2 6.3
Task-number: QTBUG-101865
Change-Id: I25b35e166a7edb6f3aaaa92a3134347804d1c6c1
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-04-25 19:39:49 +02:00
Joerg Bornemann 73284aa3cf Fix wrong include in debugutil.cpp
Commit 8398f6990b added
    #include "debugutil.moc"
but debugutil.cpp doesn't contain anything that would produce such a
file.  This leads to a flood of AutoMoc warnings when building the QML
debugger test.

Presumably, it was meant to include moc_debugutil_p.cpp, so let's do
that.

Change-Id: I86dfe935e7a01388f6737124d9383ad53a772897
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-25 19:39:49 +02:00
Ulf Hermann f7f6e14094 QQmlPropertyCache: Guarantee 1:1 relationship to meta object
The QQmlPropertyCache ctor that just takes a QMetaObject is really
dangerous. It misbehaves for anything but plain QObject. Remove it.

Also, realize that we never want to update a property cache
"recursively". That is, each property cache maps exactly one metaobject.
We cannot cover multiple metaobjects with the same property cache.

Finally, any property caches constructed dynamically must not be
recorded in the type registry. These caches are not comparable to
anything else. Introduce a special method to create them.

Fixes: QTBUG-102454
Pick-to: 6.2 6.3
Change-Id: I47a1ff0f467e9444ff9f581ffcdf0a8b5730b0b8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-25 19:39:49 +02:00
Andreas Buhr aa9a475734 Blacklist tst_qqmlenginecleanup::test_customModuleCleanup() on Android
qmlimportscanner is not told about the correct path to CustomModule.
This patch blacklists the tests while waiting for a fix.

Pick-to: 6.2 6.3
Task-number: QTBUG-102833
Task-number: QTBUG-101865
Change-Id: I9c1b1a7f6f5e52a156cb03e954959ecd5c26e1ff
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-04-25 19:39:48 +02:00
Ulf Hermann 762938aa5d Generalize QQmlAbstractBinding::isValueTypeProxy()
Instead of a bool we can just return an enum of the actual kind. This
way all the checks become more readable. Furthermore, we can eliminate a
dynamic_cast without sacrificing readability.

Change-Id: I8a38687f9b796cd47196a6ab0385624c737e4435
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-25 19:39:48 +02:00
Fabian Kosmale 759090f591 Immediately complete component upon creation failure
We do not want to wait until reaching the Component destructor (at which
point e.g. the engine might be gone).

Pick-to: 6.2 6.3
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>
2022-04-25 15:55:27 +02:00
Fabian Kosmale ed7dd5ad01 Handle property assignment failure for group property gracefully
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.

Pick-to: 6.2 6.3
Fixes: QTBUG-102425
Change-Id: Iec27cb003a81b1f72317b87297832025c74cbfe9
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-25 15:55:27 +02:00
Ulf Hermann 4ab857c37b QmlCompile: Double-check types before generating lookups
In case of incomplete type information, we can get QJSValue as output
type where we expect QObject*. We cannot generate any sensible code for
that.

Change-Id: If817de7dca3b5b0b58aff92dec2dd12a7c10d250
Pick-to: 6.2 6.3
Fixes: QTBUG-102554
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-25 08:44:43 +02:00
Andrei Golubev ff88fb0c82 qmlcompiler: Support attached property bindings
Extend group property binding creation with attached properties case

As a drive by, add extra attached property tests for QML and qmltc,
covering the case where an attaching type exists in both base and
derived types

Task-number: QTBUG-102082
Change-Id: I6c0d2b941da72d6dab7fc05a4f7b2a7875423ef0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-22 10:38:16 +02:00
Andrei Golubev 32b574314d qmlcompiler: Create group binding in group property syntax case
Cover the following case of binding on a group property:

Type {
 group { foo: 42 }
}

Task-number: QTBUG-100168
Change-Id: I0147c74dffb649907457d5f17a2ab29473101a6d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-22 10:38:16 +02:00
Andrei Golubev e739df5fcf tst_qqmljsscope: Cover a more sophisticated group property case
Document (via test) what happens when we re-assign a group property in
the derived scope

Introduce a QML test module along the way used within the test

As a drive by, add all QML test files to TESTDATA

Change-Id: Id4c3e20e45b8e0f3757840c87e0285f8516319a8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-04-22 10:38:16 +02:00
Maximilian Goldstein fc3f4e5834 qqmlsa/PassManager: Add method for checking whether module is imported
Adds a method to the PassManager to check whether a QML document has
imported a particular QML module.

This is important as a lot of linting passes only need to run when a
certain module is present and can be skipped otherwise.

Checking for the module is accomplished by adding an invalid
$module$.<URI> scope to the imported types generated by QQmlJSImporter.
This means that not only direct imports but also indirect imports caused
by a qmldir import line will be properly detected.

Change-Id: I341f916a43c60d373d205b5571104d5c5a533d61
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-04-21 21:04:01 +02:00
Sona Kurazyan 6bb384d67c Replace uses of deprecated _qba with _ba
Task-number: QTBUG-101408
Change-Id: Ie4d6d8f92241a546c9c6507a0fbb27035661d33a
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-04-19 16:39:07 +01:00
Ivan Solovev d141804e6f Android: enable tst_qqmlextensionplugin
The test was extracting plugins from the installation directory.
However on Android plugins can be read only from APK's libs subdir.
By default no plugins are copied into the APK, because they are not used.
So add a dummy.qml file which uses some basic stuff from Qt.Quick and
Qt.Quick.Controls. This will force the plugins to be copied into the APK.

Fixes: QTBUG-100169
Pick-to: 6.3 6.2
Change-Id: I31d7a407c655e19f147d461a083f27d6f6cbda72
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-04-19 17:39:07 +02:00
Andreas Buhr b7fd8ab10b Fix tst_qv4debugger on Android
tst_qv4debugger::conditionalBreakPointInQml() failed on Android
because dependencies were not available.
This patch moves qml code from strings to file, thus exposing it
to the build system. This way, the build system can take care
of the dependencies.

Pick-to: 6.2 6.3
Fixes: QTBUG-102416
Task-number: QTBUG-101865
Change-Id: Icd6ef43a45642f68e749137a963ee2ebfe462bce
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-04-13 13:56:51 +02:00
Ulf Hermann 45dcac12e5 QML: Reset the binding name when synthesizing components
The binding that creates the element inside of a Component has no name.

Pick-to: 6.2 6.3
Fixes: QTBUG-101655
Change-Id: Ib2ff272cff4f21efb588553d55d1e348e2ee5f87
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-04-11 19:37:20 +02:00
Ulf Hermann ec79af7396 DelegateModel: Use actual bindings for required properties
Tracking the change signals is brittle and error prone. We have bindings
for this case. Let's use them. We can construct a synthetic
QV4::Function that contains its own QQmlJSAotFunction. In order to pass
the property index to the function we generalize the "index" property of
QQmlJSAotFunction to contain any extra data the function may want to
use. If there is no compilation unit, we pass that instead.

Fixes: QTBUG-91649
Change-Id: I0758bcc4964a48c6818d18bfb0972e67dbc16a1f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-11 14:12:09 +02:00
Ulf Hermann 5fdb88bcc1 QmlCompiler: Fix scopeObjectDestruction test case on android
Apparently we cannot close the dialog anymore once it has been opened.
Use a non-native dialog instead.

Pick-to: 6.2 6.3
Change-Id: Iced08fe83fcaa9890d002cf91f73987c1ee97a95
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-11 12:12:09 +00:00
Andreas Buhr f9bc831600 Repair tst_qqmltypeloader on Android
Task-number: QTBUG-101865
Pick-to: 6.2 6.3
Change-Id: Ie51831f6047653ec6bb97fedff0bc46a078ae525
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-04-07 14:41:33 +02:00
Ulf Hermann 388ccd7b6f QmlCompiler: Allow retrieval of descriptive name from invalid types
Apparently we do that somewhere. It should not just crash.

Pick-to: 6.2 6.3
Task-number: QTBUG-102147
Change-Id: Id612e0543d8794aa4f334a899b117142b7a8cd38
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-07 00:18:12 +02:00
Fabian Kosmale 8e867653d8 QQmlApplicationEngine: Add a more convenient error signal
In Creator's hello-world QML example, we currently have to do quite some
unhandy logic to check whether creation failed: Connect to
objectCreated, and then check whether the object is nullptr in a
lambda.
Provide objectCreationFailed as a more convenient alternative for when
we are only interested in the error case, and do not want to do anything
with the created object.
This allows simplifying the hello world example to a simple connect of
the new signal to QCoreApplication::quit.

[ChangeLog][Qt Qml][QQmlApplicationEngine] Added objectCreationFailed
signal as a more convenient way to check for errors than objectCreated.

Task-number: QTBUG-47996
Change-Id: I6513bf726807de183a604e03379e65515e090ccc
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-04-06 21:18:20 +02:00
Ulf Hermann 8a229c38fb QmlCompiler: Analyze type conversions before reads in basic blocks
The type conversions happen before the value is read. Therefore, we need
to record them in this order. Otherwise, we may lose a type conversion
if the instruction writes the same register as it reads.

Fixes: QTBUG-102281
Change-Id: Id63a69f86af90c8dc987c0301db3958322c006a1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-06 17:12:50 +02:00
Ulf Hermann a55299615f QmlCompiler: Fix string-to-bool conversion via QJSPrimitiveValue
We had a typo in there.

Pick-to: 6.2 6.3
Fixes: QTBUG-102309
Change-Id: I11eb9d35fde3b92d2e48e845740379e10c53774a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-06 17:12:41 +02:00
Andreas Buhr e0e4cfca95 Property include test data for tst_qqmlenginecleanup
tst_qqmlenginecleanup uses test data, but in was not properly
included. This patch includes it. tst_qqmlenginecleanup does not
work after this patch, so further repairs are necessary.
But this is a required step.

Task-number: QTBUG-101865
Pick-to: 6.2 6.3
Change-Id: I4739036249565ce6b78adff8f394436d184d9ae8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-04-06 13:07:34 +02:00
Ulf Hermann 0b63f3b66d QmlCompiler: Respect qualified property types
Factor out the name construction routine duplicated all over the place
and apply it to all places where it was missing.

Fixes: QTBUG-102147
Change-Id: I7c93b4878cedf3489b978591da8d8dfbb2b98c9b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-06 05:02:34 +02:00
Andreas Buhr 377d20ad7c Fix tst_qmltc_manual for Android
tst_qmltc_manual did not find its test data. This patch
fixes it.

Fixes: QTBUG-100018
Task-number: QTBUG-101865
Pick-to: 6.2 6.3
Change-Id: I5c59937bb20f0ed904d7c1dec6ab543df9aba499
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-04-06 05:02:34 +02:00
Marc Mutz 7f349aeb31 tst_qqmllistcompositor: fix -Wdeprecated-enum-enum-conversion
Instead of an unnamed enum, make these extra flags of the correct
type, C::Flag. This is the same technique used a few lines up for
extra C::Group flags.

Pick-to: 6.3 6.2 5.15
Change-Id: I2dd5221f95bfa49c93e9cbf9d8583ac38c24de95
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-05 22:57:40 +02:00
Ulf Hermann d425712e93 QmlCompiler: Allow primitive conversion from any number to bool
Task-number: QTBUG-102281
Change-Id: I0dac4ce9c86c55e52283a6e05b0c3c0cc46551be
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-05 14:27:12 +02:00
Andreas Buhr 598bfdb139 Repair tst_qmlcppcodegen on Android
tst_qmlcppcodegen tries to start itself again using QProcess.
This does not work on Android. This patch skips this test.

Task-number: QTBUG-101865
Pick-to: 6.2 6.3
Change-Id: Ib8f9a5e028a938949347bc8e83ea483d0228968e
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-04-05 14:12:02 +02:00
Maximilian Goldstein 7c9276d38b qmllint: Integrate plugin infrastructure
Integrates the plugin and pass infrastructure into qmlcompiler and qmllint proper.
Plugins are searched for in the "qmllint" subfolder of the Qt installation's plugin
directory. In addition we also support loading statically linked plugins.

[ChangeLog][qmllint][New Feature] qmllint can now be extended via plugins. Use --plugins
to get a list of available plugins.

Original-patch-by: Fabian Kosmale <fabian.kosmale@qt.io>
Change-Id: I75a09dd978fc7724aca4931f055cc71c7ced971b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-05 14:06:56 +02:00
Andreas Buhr 93193747e8 Repair tst_qqmlproperty on Android
tst_qqmlproperty tries to start itself in another environment
using QProcess. This does not work on Android.

Task-number: QTBUG-101865
Pick-to: 6.2 6.3
Change-Id: I8e0410cf315e53899a88cf1b3c9dfba605b7f4d9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-05 13:57:56 +02:00
Andrei Golubev 5b63902d5c QQmlJSMetaPropertyBinding:add group type fetching function, extend tests
Change-Id: I754349ab5b6a8125ccc373210fc073dd71583c6f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-05 13:57:34 +02:00
Ulf Hermann aea732d607 Avoid copying QQmlJSScope
The factory should populate the pre-existing scope rather than copy it
into place. This way we can detect inheritance cycles involving the
pre-existing scope.

However, now we may detect the inheritance cycles earlier, when
resolving the types inside the lazy loading. We have the right pointers
available there now, after all. Therefore, add a way to propagate base
type errors out of the factory. When clearing the base type, we can now
give a reason for that. When checking the inheritance cycles we
retrieve that reason and log it.

We also remove the special casing of the ScopeType property of
QQmlJSScope. There is no real reason to set it in the ctor. As we
delay the population of QQmlJSScope now, we have to set it later.

Pick-to: 6.2 6.3
Task-number: QTBUG-102153
Change-Id: I49cf6e20f59fbdb6ed98a82040b3b159676f5975
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-04 09:09:49 +02:00
Mitch Curtis 6eaef57cd1 Ignore warnings in tst_parserstress::ecmascript()
We only care that the parser can parse, and warnings shouldn't affect
that.

Change-Id: I22bab85dbe6cb2f41640adaaa53cb8c85394773b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-04 09:24:54 +08:00
Ulf Hermann c12f0f07f5 QmlCompiler: Improve ambiguous type detection
When detecting an ambiguous type, we need to invalidate the entry in the
list of types, rather than delete it. If we delete it and we get yet
another version of the type, we'll add that one just like it was not
ambiguous.

Furthermore, we cannot check the type name when looking for ambiguity.
The QML name can be bent and twisted in various ways, to import
ambiguous-looking types under different names, so that they are actually
not ambiguous.

Pick-to: 6.2 6.3
Fixes: QTBUG-102153
Change-Id: Iee7951229c5f68b168899e55164e8cf91587eec1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-01 20:58:49 +02:00
Mitch Curtis a52fd0fcf3 Fix Connections warning in tst_qqmltablemodel
Declare the signal handlers as functions.

Change-Id: Ie583a123054cbc090245ccc55e7de9ac83397372
Pick-to: 6.2 6.3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-01 16:34:10 +08:00
Maximilian Goldstein bc63196948 qmlcompiler: Improve grouped property support
Still lacks support for merging and resolving grouped bindings, but
this will be handled in another patch.

Task-number: QTBUG-100168
Original-patch-by: Fabian Kosmale <fabian.kosmale@qt.io>
Change-Id: I1bb73f383acc3c8512676db47c5944f369b904b7
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-03-31 15:49:47 +02:00
Andrei Golubev 1d0ebfb4dd Add QmlModels dependency to LabsQmlModels
Some classes (e.g. QQmlDelegateChooser) depend-on / inherit QmlModels'
functionality. We need to propagate that dependency to QML via qmldir
entry, otherwise we won't be able to see the types in QmlCompiler lib

Note that we already depend more strongly (via linking) on the
QmlModels library, so there is no reason not to depend on the QML
module in qmldir

Pick-to: 6.2 6.3
Change-Id: I4f16f66f2910fb6afd38475cd6ba3209cfd1207d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-28 15:16:42 +02:00
Andrei Golubev 765bf6abdb Rework QQmlJSScope::causesImplicitComponentWrapping()
It does not seem correct to be able to use this function for both sides
of binding expressions: the property type and the assigned QML type
(`<property> : <qml type> {}`). Instead, it should really be a function
that considers both sides together (and actually checks the sides
differently!)

What we really should do for the assigned QML type is figure whether
its *first* non-composite base is a QQmlComponent - not just that it
is a QQmlComponent itself. Leave the QQmlAbstractDelegateComponent check
in place since this part is correct

The property itself, on the other hand, seems to cause an implicit
component wrapping if its type is QQmlComponent-derived (which means we
have to check the full C++ hierarchy)

As a drive by, also update QQmlJSScope::canAssign() since it used the
old function internally and was ignoring the case when a to-be-assigned
type lacks a C++ base type hierarchy (e.g. because it does not exist
ahead of time)

Pick-to: 6.3
Change-Id: I23524fa54d45d9140e1cafd9f81ef1f68d95f3a7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-03-28 15:16:35 +02:00
Ulf Hermann 3fd49c82cf Respect invokable toString() methods
We should not invoke the base toString() method if there is an override
in a more specific type. This involves lowering the priority of generic
JS lookups when resolving scope properties, in favor of context and
scope lookup.

[ChangeLog][QtQml] You can now override the JavaScript toString() method
by providing a Q_INVOKABLE method of the same name in your QObject-based
C++ classes.

Fixes: QTBUG-87697
Change-Id: I6190111f4c28e54ce76c391c69c4a921e290e612
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-28 10:28:35 +02:00
Ulf Hermann 8398f6990b Eliminate extra event loops from QQmlDebugTest
Extra event loops are famously brittle, and we don't need them here. We
can just us QTest::qWaitFor().

Task-number: QTBUG-101678
Change-Id: I73837bc323c83431f487db3cac6872736635d557
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-24 14:33:16 +01:00
Ulf Hermann 185760fa44 V4 ArrayIterator: Protect retrieved value from GC
When constructing the iterator return object, the garbage collector may
run, and drop the element value we want to return.

Fixes: QTBUG-101700
Pick-to: 5.15 6.2 6.3
Change-Id: I60c9b0b9fbb9e784fa089a8b5bb274d02ef7fc1f
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-03-24 14:32:51 +01:00
Ulf Hermann cc6bd22b61 Add public API for retrieving the extension object
Change-Id: I28bc1c177cb78d85d844c7a5cd5b6710db8fd65d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-03-23 23:21:56 +01:00
Ulf Hermann 5901fba811 QmlCompiler: Fix a number of warts regarding type lookup
There was a condition missing in qqml.cpp making most type lookups crash
right away. Furthermore, we need to generate code for type lookups we do
need. Finally, the shadow check should skip instructions we don't need
anymore. Shadowing in optimized-out code is not very interesting.

Pick-to: 6.2 6.3 6.3.0
Change-Id: I34e9de7686528b39a35e59c616e4e28b32a6e031
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-23 12:29:26 +01:00
Ulf Hermann aff516954d QML: Load qmldir-imports also for the implicit import
Since we load plugins and C++ based types, too, we should just load the
dependent imports as well. Otherwise this is rather confusing.

Fixes: QTBUG-101752
Change-Id: I5bd8afa22e5f16141ef8b47c1a40d3ba8698106c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-22 21:53:21 +01:00
Ulf Hermann 8a9607acfc QmlCompiler: Support type lookups in prefix-imported modules
We just have to return a plain metaType if it's neither an attached type
nor a singleton.

Pick-to: 6.3
Fixes: QTBUG-101811
Change-Id: I6a78ffe4504606d0cb34f1a6ca9d5511a3447d7f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-22 17:47:47 +01:00
Volker Hilsheimer aee6b231d0 Fix warnings in tests after QQmlListReference change
The engine parameter is no longer used.

Pick-to: 6.3
Change-Id: Ifc630eb4803a015d41df50210bd86947f6a5a472
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-03-21 12:45:58 +01:00
Volker Hilsheimer 3a857c0107 Fix compiler warning from deprecated API
tst_qqmllistreference.cpp:828:23: warning: 'QQmlListReference' is deprecated:
Drop the QQmlEngine* argument [-Wdeprecated-declarations]

Since without the engine argument the test case is identical to the
previous block, we can just as well remove it.

Change-Id: I4e4b29a69dfdd60ed1678361d7796739ecead41e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-21 12:45:13 +01:00
Volker Hilsheimer f85790d097 Fix warning in test when iterating QJsonArray
QJsonArray doesn't hold QJsonValues, so we can't iterate over references.
Use QJsonValueConstRef instead.

Change-Id: I0246e2406b2f3d5aa2cd5382d17396717d899dfa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-21 06:14:56 +01:00
Volker Hilsheimer 9a2bbcd21b Fix warning after QString::count deprecation
Pick-to: 6.3
Change-Id: Id91980b01def84ff56212a267aca805ac7deb192
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-20 20:47:22 +01:00
Volker Hilsheimer 6fca2c1a6d Build tests without warnings after qtbase changes
Replace deprecated QString::count with QString::size or QString::length,
depending on context, and use qsizetype instead of int.

Pick-to: 6.3
Change-Id: Ie4c08abd2cf2ba771c23e8def72756170cc07af7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-18 22:56:54 +01:00
Ulf Hermann 7b8e6714e1 QQmlDebugProcess: Remove cruft
The mutex had no function I can discern as the class is not thread safe
in any way, and isn't used from multiple threads anywhere. Extra event
loops are famously brittle. We don't have to use an extra event loop
here. QTest::qWaitFor will do just fine.

Task-number: QTBUG-101678
Change-Id: If25a961312a1eeb725ff779e386b2657e0f23dd1
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-18 22:56:53 +01:00
Ulf Hermann 08d0fb39b9 DebugTranslationService: Do not show a window in the test
The test works fine with the window hidden. Trying to show it gives
problems in the CI. We also want to avoid showing windows in non-GUI
tests as far as possible.

Fixes: QTBUG-101738
Pick-to: 6.2 6.3
Change-Id: I206f74f940e6ba7ac6346c85459b896387ab85a5
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2022-03-18 22:56:53 +01:00
Shawn Rutledge ae3d6a0a65 tst_qqmllanguage::extendedForeignTypes: check signal with an argument
Check that this kind of signal is also accessible in the "extended"
QML type.

Change-Id: I81ba60c23dc96723a97f1b3df5b0a6c46dba77ba
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-03-15 20:53:33 +01:00
Maximilian Goldstein 01cde42d5d qmllint: Make "Did you mean" look in extension types as well
Makes sure we also look for suggestions in extension types. Adds two new
methods to QQmlJSScope called properties() and methods() to easily get
all of them across base types and extensions.

Change-Id: I5874c0221bac6d6e317b79146227bf749100f05b
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-03-15 12:55:56 +01:00
Maximilian Goldstein 650fa4bc36 tst_qmllint: Use library for unqualified access checks
This is a lot faster and a bit less messy.

Change-Id: Ia43549ad63875a80774d199bcaee2453d16bf3dd
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-03-15 09:01:45 +01:00
Ulf Hermann 922b95ea15 QmlCompiler: Avoid some deprecation warnings
QString::count() is deprecated, and also the "engine" argument to
QQmlListReference. Also, properly convert the results of "length"
retrieval.

Change-Id: Ib7edde1326a0347902174a23147086b9deccfe17
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-14 20:53:52 +01:00
Ulf Hermann 6eff3465b5 QmlCompiler: Implement generate_DefineArray
Using the type cloning and adaption mechanism we can now determine what
kind of list we have to create in order to avoid a later conversion. We
can even propagate the type adjustment into the element types we read.

Fixes: QTBUG-100157
Change-Id: Ia2f160ebae56f39ee5946f49d2f8c5b4986a6b77
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-14 20:53:52 +01:00
Ulf Hermann 9de2b11a70 Make most QQmlPropertyData const
You really should not mess with that after creating the property cache.

Change-Id: I070200772475bb67f539dbbd85a298020b14ca79
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-14 16:44:35 +01:00
Ulf Hermann e5246cafff Use const QQmlPropertyCache wherever possible
We're not supposed to modify property caches after they've been created.

Task-number: QTBUG-73271
Change-Id: I0ab8ed6750508fa4e28931995142f56cd5fa3061
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-14 16:44:35 +01:00
Maximilian Goldstein f6e6771647 qmllint: Make "Did you mean" support enums
Previously we didn't search for possible fixes for typos in enum keys,
this change makes sure we can also offer corrections for enums.

Also adds a convenience method to QQmlJSScope so we can get all
enumerations across base types and extensions.

Change-Id: Id1f79a9d0a2a3b54b2ad3dfb7d8a71e6a276ce39
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-03-14 09:43:20 +01:00
Maximilian Goldstein a398e06c61 qmllint: Support automatically applying suggestions
We now support automatically applying fix suggestions that don't
need any additional user input. This allows us to automatically
solve issues such as unqualified access and multiline strings.

[ChangeLog][qmllint][New Feature] Added the ability to automatically
fix some warnings, use -f to automatically fix your files or add
--dry-run to see what changes would be made first.

Change-Id: I2dc7587137d74267f60c08bb94a035f1a85a62b1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-14 09:43:15 +01:00
Fabian Kosmale 7255b7db30 tst_qmltyperegistrar: Use qt_autogen_tools_initial_setup
Otherwise, it will break top-level builds, as moc might not have been
build yet.

Fixes: QTBUG-101617
Pick-to: 6.3
Change-Id: Id938c2e96575b6f2ad65cd5d6f8fe2af1421b02a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-13 18:31:55 +01:00
Tatiana Borisova 09cb6a4952 Add several autotest cases to Minimal set for STATIC build
- It is not possible to build all autotests for STATIC build, because
  CI doesn't have enough resources.
  But it is possible to build a few tests on CI for INTEGRITY testing.

Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: I698edb9cd0696dd55e1b82547cb57c34b993bb10
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-10 23:33:36 +02:00
Mårten Nordheim af7d0957e4 Fix deprecated uses of QScopedPointer
Which is uses of take() and swap().
And replace it with std::unique_ptr.

Change-Id: I2580383c1d2af0ba6103a66f034235905e0988ac
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-10 21:02:58 +00:00
Maximilian Goldstein 8848fba018 tst_qmllint: Introduce a Result struct
This helps make our tests more structured and will also allow for
many other improvements down the line.

Also gets rid off our hack of constructing fake logger messages to
check against.

Change-Id: I0bbafc32c99ecb7abc7be1c6416e4d5903aff22c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-09 12:40:06 +01:00
Assam Boudjelthia 841217b988 Rename android_dummy_imports.qml to dummy_imports.qml
Amends 16f0d38d56.
From 0fc8a511ba, it seems that
not only Android is relying on these imports to satify
qmlimportscanner, but also Integrity. So rename the imports
to something generic and remove the explicit mention for Android.

Pick-to: 6.2 6.3
Task-number: QTBUG-97056
Change-Id: I9273fd0f9201a805cad4d588847796f7daecb686
Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-03-05 15:23:48 +00:00
Assam Boudjelthia c67e7922f2 Reduce the length of Int8Array in tst_QJSEngine::typedArraySet()
On 32-bit Android x86 using a length of 0xffffffe throws an
"RangeError: ArrayBuffer: out of memory" instead of the expected
"RangeError: TypedArray.set: out of range".

Pick-to: 6.2 6.3
Task-number: QTBUG-99193
Change-Id: Id6deea18fe90228db616ddc7550c7832825c297a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-03-05 09:48:16 +00:00
Ulf Hermann 464abaec05 QML: Unify treatment of invalid revisions on registration
Revisions before QML_ADDED_IN_VERSION and revisions after
QML_REMOVED_IN_VERSION should both result in anonymous types. This way,
you can then derive from the type in question and expose the derived
type in a different set of versions.

Pick-to: 6.3
Change-Id: Ia59258047fc242c809c27525bb75fd2797fe5aab
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-05 07:20:08 +01:00
Ulf Hermann 1e722f5e8e QML: Handle dynamic meta objects in AOT lookups
If we are dealing with dynamic metaobjects, the QML engine may not
create property caches. We cannot see this at compile time. Therefore,
we need to establish a fallback infrastructure that does the same
operations on plain QMetaObject.

Pick-to: 6.2 6.3
Fixes: QTBUG-101349
Change-Id: I8c936fc077b0018df71196620b6987825253cb39
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-03 18:44:38 +01:00
Maximilian Goldstein 8dd7201994 qmlcompiler: Improve required property warnings
When a property is required after declaration, now show the scope where
it happens including full location information and context.

Change-Id: Iddd2d0e543406ab479b4af1a5e74682328998d74
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-03 11:19:54 +01:00
Kimmo Ollila 0fc8a511ba INTEGRITY: Fix some test cases from core/qml folders
-Add dummy_imports.qml to TESTDATA
-Let qmlimportscanner handle plugin import
-Skip cases that depend on mounted filesystem

Task-number: QTBUG-99123
Pick-to: 6.3 6.2
Change-Id: I99e21e423f2114c4c4ee1e24bdf9bb85af51baf7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-03-03 08:26:06 +02:00
Maximilian Goldstein ae441425e2 tst_qmllint: Fix absolutePath() test
Previously the test would always return true regardless of whether or
not the feature was actually working properly. Now the feature is both
used by default for all tests and properly tested in an enabled and
disabled state.

Change-Id: I9fc76319b83ba345da20f2d7c16272593bd5ca3f
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-02 14:21:09 +01:00
Pasi Petäjäjärvi 39855a3ba1 tst_qmltc::listView is failing with no apparent reason
Pick-to: 6.3
Task-number: QTBUG-101342
Change-Id: Ib660394b5956b891b86dd20cab83c80f5274fa43
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-03-02 15:21:09 +02:00
Assam Boudjelthia 16f0d38d56 Android: unify the android tests dummy import files
This renames all qml files added before to allow qmlimportsanner to
include the necessary modules into Android packages, into
android_dummy_imports.qml, and also adds a comment in each one
describing why it's needed.

Pick-to: 6.2 6.3
Task-number: QTBUG-97056
Change-Id: I7fc0514dd9e5bc10849fdd0503547e1a75242414
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-03-02 15:21:09 +02:00
Assam Boudjelthia 6c3373109f Disable failing declarative tests on Android - Part 2
This allows us to enable testing on declarative for the module
as a whole and have some sort of test verification for the mean
time, and fix the fails over time.

This also disable tests like qdom and qjsscope which are host tests.

Pick-to: 6.2 6.3
Task-number: QTBUG-100991
Task-number: QTBUG-99194
Task-number: QTBUG-101005
Task-number: QTBUG-101006
Change-Id: Ie7ae5b8e0ccdf2f55ce3568091d513a073c48417
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-03-02 13:21:09 +00:00
Assam Boudjelthia 9bdfea7f1f Android: various test fixes
2nd round of test failures fixes for Android. Mostly resource bundling
related issues still.

Pick-to: 6.2 6.3
Task-number: QTBUG-97056
Change-Id: I2fac0710a7b5528fcef4480babd0cbf749e488b3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-03-02 15:21:09 +02:00
Maximilian Goldstein 31abba8cdc qmlcompiler: Suggest fix for multiline strings
We can now suggest a template string to use instead that is properly
escaped. Once auto-fixing becomes available we can automatically replace
deprecated multiline strings with the new suggestion.

Task-number: QTBUG-92448
Change-Id: I4e77820b66ae960cde558a62689c5da328b8df5b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-02 14:21:08 +01:00
Maximilian Goldstein 7e7582fc70 qmllint: Remove extra space from unqualified access fix suggestion
This looks bad and doesn't follow our coding guidelines or what our
formatter would produce.

Change-Id: Iceccb4cd1d9cccd84d49ded426f7ce184839b095
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-03-02 14:21:08 +01:00
Andreas Buhr 85b086a97b Fix compilation of tst_qmlcppcodegen on Android
It seems MOC does not like methods named "isnan" on Android.
It generates a call to "__builtin_isnan".
This patch is a workaround. A real fix in MOC would be better.

Pick-to: 6.3
Change-Id: If73a4d7580ac51f6c60f4fb92c9699d077f4452f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-02 14:21:08 +01:00
Ulf Hermann 88e96debfd qmltyperegistrar: Tolerate and warn about invalid URIs
If you give qmltyperegistrar an invalid URI it should still not generate
invalid C++ code. In fact the module will still be somewhat usable. You
just cannot import it.

Pick-to: 6.3
Task-number: QTBUG-101072
Change-Id: I21232f99c1ef486a62dbe339f7d0ae1b9abc8871
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-02 08:59:50 +01:00
Ulf Hermann 1240a440f2 QML: Explicitly reject malformed file imports
You cannot just pass a resource path or absolute path. We expect a URL
after all. A relative path is a relative URL, so you can pass that.

Pick-to: 6.2 6.3
Fixes: QTBUG-98181
Change-Id: I010bc08b8cb0ff06712f7b0353955bee96ae36c1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-02 08:59:46 +01:00
Ulf Hermann 074b66e007 QmlCompiler: On MoveReg, check if we need to move at all
As we don't store void, null and empty lists, moving those is a noop.
Don't generate invalid code for that.

Pick-to: 6.2 6.3
Change-Id: Ica6714acd0ce8a5ddca44d9a397e776eb3df4247
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-01 08:51:52 +01:00
Ulf Hermann 23ab2e0f55 QmlCompiler: Correctly label arguments and return types of JS functions
Returning void from any JS function doesn't quite cut it.

Pick-to: 6.3
Fixes: QTBUG-101285
Change-Id: I199813627614061ec25139277e8ea23cb844aac5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-02-25 14:08:22 +01:00
Ulf Hermann 78e3b774ad QmlCompiler: Don't assert for the "int" type if we don't need it
If there are no enums in a type, we don't need the int type to resolve
them. This is commonly the case for sequence types.

Change-Id: I18b2960ef845ef797b6ef6d755648e6add1854db
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-24 12:16:41 +01:00
Ulf Hermann 57614680f7 QQmlMetaType: Don't duplicate notify signals for extended types
We have to add the methods first, so that the properties can be
associated with their proper notification signals once we add them. If
we add the properties first, the "missing" notification signals are
synthesized.

Pick-to: 6.2 6.3
Fixes: QTBUG-101155
Change-Id: I1aacbf33a24f7a98d05dece77c804bd7cba8a041
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-24 08:33:14 +01:00
Ulf Hermann c8e756e560 QML: Take care of QVariant when converting function arguments
We cannot convert to QVariant using QMetaType::convert(). But we can
just construct a QVariant with the desired type and data. This will
become an issue once we automatically convert argument types to match
the desired type inside the function.

As a side effect, also allow declaring "var" arguments to functions.

Change-Id: Idc14021d8d85d3d09ee7b7f286de91b56ea02bfd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-23 12:09:42 +01:00
Fabian Kosmale 6b5aa14596 tst_qqmlmetaobject: Clean up even when test fails
Change-Id: I017d44a23be40466068ee08c90a5bb3f721ba14f
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-02-22 23:34:46 +01:00
Maximilian Goldstein 1829d7c64c qmllint: Properly warn about calling properties
Previously whenever a property was called the warnings qmllint emitted
made it seem like the property was just not found instead of not being
callable.

Now we will warn if you try to call a property and warn about
properties shadowing methods, slots or signals. We also discourage
calling variant properties now that may or may not be a function.

This change also fixes an assert being hit in isMissingPropertyType
due to our previous, lackluster checks.

Fixes: QTBUG-101074
Pick-to: 6.3
Change-Id: I0790b4a4584f3430ee1d8ddf549611225a36cc5b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-22 16:52:54 +01:00
Maximilian Goldstein e2864d6aa9 qmlmodels: Move QModelIndex from QtQml
Moves the QModelIndex value types from QtQml to QtQml.Models as they
cannot otherwise be properly resolved in tooling.

Pick-to: 6.3 6.2
Fixes: QTBUG-100338
Change-Id: I30fc18b388974238ba8353e87ef09f57f8ceabd1
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-21 18:20:57 +01:00
Ulf Hermann 88147eb3f6 QmlCompiler: Avoid infinite loop in dead store elimination
We have to mark the required variables also in block 0. And we shouldn't
generate empty blocks.

Pick-to: 6.3
Fixes: QTBUG-101011
Change-Id: I0dd19f69f45f507cb83e2ddfba3060de48a940b4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-18 16:48:50 +01:00
Ulf Hermann d0f4e0c037 QmlCompiler: Perform QVariant conversion in JavaScript semantics
In JavaScript we have a number of extra conversions not covered by
qvariant_cast. Therefore, add a method to perform a QVariant conversion
in JavaScript semantics to QJSEngine, and use that in the compiler.

Pick-to: 6.3
Fixes: QTBUG-100883
Change-Id: I8b0bfa0974bc6b339d2601fb373859bc710788c8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
2022-02-18 12:13:47 +01:00
Ulf Hermann 69fefd94e8 QmlCompiler: Do not crash on attempts to lookup a function in the scope
Rather, reject the code and let the engine handle it.

Pick-to: 6.2 6.3
Fixes: QTBUG-100980
Change-Id: Ibcd1249ba3550b40121622752b4ca22d1df3ed2a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
2022-02-18 12:13:47 +01:00
Ulf Hermann 795d7dafe5 QmlCompiler: Do not generate block comments into C++ code
The code we're commenting could again contain block comments. You cannot
nest them.

Pick-to: 6.2 6.3
Fixes: QTBUG-100978
Change-Id: I78685bf29dd30f05e5a3b17abc43ba0b4cb6849e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2022-02-18 12:13:47 +01:00
Ulf Hermann 4c716dd19c QmlCompiler: Correctly encode inf/nan/-0 into C++
Pick-to: 6.2 6.3
Fixes: QTBUG-100947
Change-Id: If0b05adac91f687daf697f3510e4cf48e7de4537
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-18 12:13:47 +01:00
Maximilian Goldstein 696f89b198 qmllint: Warn about missing property types on current scope
Previously we only warned about missing property types when the lookup
was not on the current scope but only on an id, parent etc.

This change makes sure we also warn in this case and don't produce false
positives for an unqualified access.

Pick-to: 6.3
Task-number: QTBUG-100839
Change-Id: I732b8420c0c6b96dd8f93cde66a7f9813e704671
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2022-02-18 12:13:47 +01:00
Andrei Golubev 68924be5b5 qmltc: Handle (simple) deferred properties correctly
Simple deferred properties occur quite often in QML (throughout
Qt Quick, for example), so qmltc should be able to deal with
them as with deferred properties

Ignore generalized group properties, PropertyChanges and similar
types for now. They require more testing and are well out of
scope of the tech preview

Pick-to: 6.3
Task-number: QTBUG-100053
Change-Id: I0f3588789d188cd6bec81de0b61d3205b665a917
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-17 12:30:06 +01:00
Volker Hilsheimer cccca1ec0e Fix build after QJsonArray change to use QJsonValueConstRef
Follows up on qtbase:f5762cd4b3130a650044863c5be132056f05daa5.
Use auto instead of specific QJsonValue*Ref type to avoid need for
orchtestrating with dependency update.

Change-Id: Ib47d5d8ab8373562684b42a90c97634e07869328
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-16 14:44:39 +01:00
Fabian Kosmale 868d90eba7 Unblacklist tst_qmlformat::testExample on most platforms
Task-number: QTBUG-98494
Change-Id: I070aa0005612d98c45923e2a97f175e9972fb849
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-02-16 14:44:39 +01:00
Andrei Golubev 2a9e514c89 Treat warnings as errors in qmltc
qmltc should really interpret most of qmlcompiler warnings as errors.
There could be exceptions but for now let's just reject any malicious
code (except for ControlsSanity since it is itself malicious)

Fixes: QTBUG-100052
Change-Id: Ib18741d0a46c4d0ddb40b53e34658804c0245018
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-15 08:55:14 +01:00
Maximilian Goldstein 2ea887cca0 qmldir: Allow for specifying default imports
Adds the option to specify default optional imports in qmldir for
tooling to load. Previously we would just load all entries.

This allows code that that relies on modules utilizing optional imports
(i.e. everything utilizing QtQuick.Controls) to still be supported in a
limited capacity.

This change also adds the necessary CMake API to add these entries to
qmldir files. It also disables loading optional imports by default
and only leaves them enabled for qmllint.

Change-Id: Iff6aaac9cb0ec72b7a2853b60840a4d28c84aa25
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-14 12:38:10 +01:00
Maximilian Goldstein 0f0987c160 QtQuick: Add proper QInputMethod singleton
Allow for accessing QInputMethod via a singleton instead of
Qt.inputMethod

[ChangeLog][QtQuick][New Feature] Qt.inputMethod can now also be
accessed via the InputMethod singleton. This allows you to use
QInputMethod in a way supported by tooling and the compiler.

Fixes: QTBUG-95540
Change-Id: I3366757a1253b202f1fe5320e54c96b70e3b273b
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-02-14 12:38:10 +01:00
Fabian Kosmale 4f50697e6c Do not rely on transitive includes in tests
Change-Id: Icb68dbecab6f675352cd58333c82fa6648025367
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-14 12:38:10 +01:00
Ulf Hermann 89b7e8def6 QmlCompiler: Allow assigning empty lists to list properties
Generate an empty list when creating a list with 0 elements.

Task-number: QTBUG-100157
Change-Id: I3b0fe0b737a8ec5257785ae32231f4b687d3b204
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-14 12:38:10 +01:00
Andrei Golubev a099030009 qmltc: Unskip important tests
They were QSKIP-ed before due to issues with importing and own module
qmltypes handling. At this point this should all be fixed with proper
QML modules so no reason to leave them as skipped

In the process of doing this, also figure that attached property code
generation is borked and fix accordingly: the compiler used an
attached type where an attaching type should've been used. Given the
obvious naming ambiguity, this was likely a typo of sorts

Also as a drive by, actually write a test for private properties which
were before only covered through QQuick-based tests on anchors and such

Pick-to: 6.3
Change-Id: I1e4fd4d916ad3bd1bacf2aee1ce2346f9283c70d
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-12 23:21:29 +01:00
Andrei Golubev 690b7cb6a2 Redesign QQmlJSLogger internals
High-level goal: be able to reuse existing infrastructure
"as is" to configure semantic analysis categories in tools
(qmllint, qmltc, qmlsc, etc.)

To achieve that, simplify the logging to always "log"
something, without explicitly specifying the severity. The
severity is now baked into the category (and we can extend
those to cover different cases)

One slight deviation is the cache generation which likes
to do its own thing at present. Provide a "forced logging"
option where we can specify which severify we want. The
hope is that this gets removed at some point

Particular list of (noteworthy) changes:
* No more "thresholding" by the level (this is rarely needed
  and is actually questionable). Instead, we can ignore a
  particular category explicitly
* Category levels are repurposed as category severities
  (at least from the high-level picture that always should've
  been this way)
* log{Warning,Info,Critical} removed. We use category severity
  instead
* "category error" makes zero sense so removed: if our severity
  is:
  - QtWarningMsg (qmllint), it is already an "error"
  - QtCriticalMsg (compilers), it is already an "error"
* Align m_output and m_{infos,warnings,errors} stored information
* Accept the fact that we don't support QtDebugMsg and QtFatalMsg
* Additional categories added to cover for places where the same
  category would be both an error and not an error

Task-number: QTBUG-100052
Change-Id: I3cd5d17d58be204f48428877bed053f756ac40a8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-12 23:21:29 +01:00
Ulf Hermann f99b2cce65 QmlCompiler: Don't store void and nullptr
We know what those are. We don't need to put them into the generated
code. Do reserve variable names for those types, though. That makes
things easier.

Change-Id: I526eb862d1f5297bc3ddf91792eba87ef67fb9d2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-12 20:03:12 +01:00
Marc Mutz 94c63a7f12 tst_qqmlqt: reliably call QDesktopServices::unsetUrlHandler()
Use QScopeGuard instead of manual calls, so even a failed test will
properly clean up after itself.

Pick-to: 6.3
Change-Id: I321f3560557e58b16cd177c623cb78b5b25111a7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-12 11:11:59 +01:00
Andrei Golubev 4d98aa998e Extend tests for DeferredPropertyNames
Document some extra behavior details through tests

Pick-to: 6.3
Change-Id: Id05da7983406a0a61e78496a8e6483e10a7c38d1
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-11 21:20:09 +01:00
Ulf Hermann d2737bdedb QML: Clean up sequence registrations for value types
We want to be able to construct a meaningful list type by surrounding
the internal name of the type with QList<>. Usually this works because
of the way we auto-register sequential containers for types. Only for
the builtins we need to do some special casing. That special casing
should happen in the builtins, not in QtQml, though.

The generic QList<foo> sequence type is implicitly given for any value
type foo these days. There is no need to mention it in .qmltypes.

QtQml retains some extra container declarations that are not straight
QList<foo> for a value type foo. Everything that's registered by the
value type registration anyway is dropped.

We keep the aliases QStringList and QVariantList in the builtins because
they are really common.

Since we now register QVariantList the way it's mandated by the
builtins, we also have to handle it correctly in qv4sequenceobject.cpp.
In particular, we need to append variants as-is rather than poking into
them.

As QStringList is an additional builtin now, we need to teach the type
resolver about it.

Change-Id: I0dfb5b780b27250f36f6886bc4e0926a03c114b4
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-11 09:36:59 +01:00
Andrei Golubev 121457933d qmltc: Explicitly unsupport singleton types
Pick-to: 6.3
Change-Id: I05525f884f239c954527f24ad8842b108b32aff1
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-02-08 14:47:51 +01:00
Maximilian Goldstein ccb437ec4f qmlcompiler: Support accessing vars in JavaScript files
We basically had all the code in place already, all that remained was
to use the information we have in the type resolver. This change also
allows us to differeniate between const and non-const bindings now.

Fixes: QTBUG-100444
Change-Id: Ia4dac3647a2aa3c557916e6ec1be63a46bcc6ce0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-05 00:30:12 +01:00
Ulf Hermann 2f87f7f144 QmlCompiler: Discern between internal and anonymous imports
Anonymous imports are imports of QML types that aren't visible in the
current document. Internal imports are imports of C++ types, also
invisible, but potentially of the same names.

Before, types with exports were added to the qmltypes container using
their exports if any matched. If there were no exports, we constructed a
synthetic name and inserted that. However, as the nullptr example shows,
we need a reliable way to find them by their internal names, no matter
if exports are present. Therefore, we now consistently add them by their
internal names using the new $internal$ prefix.

Change-Id: I42ac2447cd924d09970c24554e1e2a5e631c5f79
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-05 00:30:12 +01:00
Ulf Hermann db6459665c QmlCompiler: Place code for CmpNeInt in parentheses
Otherwise it will apply the '!' to the first argument.

Fixes: QTBUG-100480
Pick-to: 6.2 6.3
Change-Id: Iaefa25d062ad8bbd9d4278ffeaa52fc53ed417e2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-04 15:55:00 +01:00
Maximilian Goldstein 07917626f5 qmlcompiler: Remove qmllint library
Since all of the superfluous components of qmllint have been
removed now, we can just move what little custom linter logic
remains to qmlcompiler.

Change-Id: I91c752cb895e7d6c6f2dd4e2ccafb6cd05afa225
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-03 22:55:53 +01:00
Maximilian Goldstein dc9de38abe qmllint: Warn about missing singleton pragmas/qmldir entries
This change adds a warning if we encounter a component marked as a
singleton in a qmldir file which does not contain a pragma
Singleton entry and vice versa.

Note that the warning only gets triggered if the singleton is
actually used.

Fixes: QTBUG-98558
Change-Id: Id7c63f48ba49759c15dffcaee0270c7caab2eb7d
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-02-03 11:17:34 +01:00
Pasi Petäjäjärvi d245985f0b Skip tests that call qmlcachegen when cross-compiled
qmlcachegen is not meant to be available on the target.

Fixes: QTBUG-100366
Pick-to: 6.2 6.3
Change-Id: I5cbaa62e85d9a5dd6467840eb4e3ba5e3b63857c
Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
2022-02-03 00:52:49 +01:00
Ulf Hermann 41a5c7b223 V4 Date: Support another nonstandard date format QDateTime has dropped
Amends commit 43eaa77e8e.

Fixes: QTBUG-100377
Pick-to: 6.2 6.3
Change-Id: I01028bd991b8a64bd9dcad31ce90536d83dad0a1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-02-03 00:52:49 +01:00
Andrei Golubev 8a72c68446 qmltc: Rely on QQmlJSResourceFileMapper
Similarly to qmllint, we should use QQmlJSResourceFileMapper
in qmltc. This should in theory allow us to avoid
implicit import dir vs qmldir path issues (where the former
comes from source dir while the latter comes from build dir)

At present, it does not seem to be the case, however. But
this is to be addressed separately

Task-number: QTBUG-100103
Pick-to: 6.3
Change-Id: Ie85799cb0a4b8b1620964000bc5939e9d046678e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-02 21:54:33 +01:00
Andrei Golubev 6380f10185 Restructure QML module of qmltc tests
Use a more canonical qmlcppcodegen-like structure, showcasing a better
QML module

As this change makes a single QML module instead of two QML modules
(for the _diskcache and _nodiskcache scenarios), there are pros and cons

Pros:
+ Prepares us for proper introduction of QQmlJSResourceFileMapper
+ Theorically allows tests to avoid (additional) weird imports

Cons:
- Denies the ability to test generated types under default QT_NAMESPACE
  (in addition to user-provided namespace). This is fine as we don't
  need this feature until we are able to compile QQC2 and modules alike

Task-number: QTBUG-99198
Task-number: QTBUG-100103
Pick-to: 6.3
Change-Id: I13a594a1859719bc0af3370029e6be7b1744656b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-02 21:54:29 +01:00
Ulf Hermann eeec9f03e9 JavaScript: Make "this" available in blocks inside arrow functions
Fixes: QTBUG-98039
Pick-to: 6.2 6.3
Change-Id: I51ff36994fa0f3f3568c8114cb6841f677f64bc4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-02 09:27:21 +01:00
Ulf Hermann bf38043b61 CMake: Include upper case .js and .mjs files in qmldir
You can use them as singletons.

Pick-to: 6.2 6.3
Fixes: QTBUG-100326
Change-Id: I8e07600657bd43ba8376279ffe39cfa5d3213c38
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-01 15:21:27 +01:00
Pasi Petäjäjärvi 9c63dfd249 QNX: suppress QEXPECT_FAIL() on two tests it passes
As QNX's support for feature timezone uses the TZ backend,
V4's Date.timeZoneUpdated() works, as on Linux, so tests for
this method now pass.

Pick-to: 6.2 6.3
Change-Id: Ie6c318023bdf508d9f2067ca3fa9d77b78292be5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-31 16:57:19 +00:00
Ulf Hermann e7db279c28 QML: Allow declaring and binding list<foo> properties in one step
We apply the same trick we already use for the UiObjectMember rules: We
add an ExpressionStatementLookahead before the T_LBRACKET starting the
UiArrayMemberList.

Task-number: QTBUG-82443
Change-Id: Ibdb3111b7721d2af087c14b79538dee131b8e301
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-31 13:41:39 +01:00
Assam Boudjelthia f22d884faf Disable failing declarative tests on Android
This allows us to enable testing on declarative for the module
as a whole and have some sort of test verification for the mean
time, and fix the fails over time.

Pick-to: 6.2 6.3
Task-number: QTBUG-100003
Task-number: QTBUG-100014
Task-number: QTBUG-100016
Task-number: QTBUG-100018
Task-number: QTBUG-100020
Task-number: QTBUG-100021
Task-number: QTBUG-100164
Task-number: QTBUG-100166
Task-number: QTBUG-100167
Task-number: QTBUG-100169
Task-number: QTBUG-100171
Task-number: QTBUG-100173
Task-number: QTBUG-100175
Task-number: QTBUG-100176
Task-number: QTBUG-100177
Task-number: QTBUG-100191
Task-number: QTBUG-100253
Task-number: QTBUG-100254
Task-number: QTBUG-100256
Task-number: QTBUG-100257
Task-number: QTBUG-100258
Change-Id: I85bf1501b94f04853a1ca715e35df0a56041308a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-31 14:41:39 +02:00
Andrei Golubev b1bb4c8e5f Distinguish property change signals from user-defined signals
Do not expose this information to qmltypes just yet, though,
as this seems irrelevant at the moment

Pick-to: 6.3
Change-Id: Iffd8901ef9899a0fff226e8799bf45c1d688b92b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-31 08:57:52 +01:00
Pasi Petäjäjärvi 584c912dbb QML: Disable host debugging related tests when cross compiling
Disable tests that are meant to check debugging features using host
binaries. No point running those tests on actual targets.

Pick-to: 6.2 6.3
Change-Id: If020dfa00410668a305013254617fd50a0a01175
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-29 11:36:02 +00:00
Pasi Petäjäjärvi 5bc77e9b9c QNX: Force logging to stderr
Sub-process output is by default going to slog2 in
QNX so we need to force output to stderr instead.

1: FAIL!  : tst_qqmlapplicationengine::application(delayed quit) 'QString(testStdErr).endsWith(QString(expectedStdErr))' returned FALSE. (
1: Expected ending:
1: qml: Start: delayedQuit.qml
1: qml: End
1:
1: Actual output:

Pick-to: 6.2 6.3
Task-number: QTBUG-76546
Change-Id: I4a7b6c25b079f7dcc479fc2bcbd3b079bd7bc519
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-29 11:35:54 +00:00
Pasi Petäjäjärvi 7fcc9c7f58 QNX: Decrease number of objects created in tst_QJSEngine::newQObjectRace
This test is so slow on QNX that it times out:

QFATAL : tst_QJSEngine::newQObjectRace() Test function timed out
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QGuiApplication(0x169b0a6b90),
parent's thread is QThread(0x37eb7070f0),
current thread is QThread(0x37eb734150)
FAIL!  : tst_QJSEngine::newQObjectRace() Received a fatal error.

Task-number: QTBUG-99168
Change-Id: I623bff212b8334af60198e52bc283cc97187c3a7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-29 11:35:48 +00:00
Pasi Petäjäjärvi 856df4380a QNX: Disable ecmascriptests
For QNX tests are run on qemu which is slow so the tests will always
timeout. As currently timeout is set to env via CMakeLists.txt it
does not have effect on QNX as that env variable is not passed over
SSH connection. Running tests on QNX qemu takes ~30min:

PASS   : tst_EcmaScriptTests::cleanupTestCase()
Totals: 4 passed, 0 failed, 0 skipped, 0 blacklisted, 1782249ms

Pick-to: 6.2 6.3
Change-Id: Ief1ccb05ce21bf3140554272708c95ca5515bc23
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-29 11:35:40 +00:00
Ulf Hermann b0fc028cb5 QML: Allow named lists of value types
We register QList<T> as sequential container type for any value type T
we get. This way we can always find a type to use for list<t> with t
being a value type. The metatypes are shuffled around so that we have an
easier time associating a type with its list and vice versa.

As QQmlPropertyData's isQList flag denotes both QQmlListProperty<T> and
QList<T> now, we need to use QMetaType::IsQmlList more often.

Conversely, any name given to extra sequential containers registered via
QML_SEQUENTIAL_CONTAINER is explicitly ignored now. As you can do
list<foo> for any type foo now, there is not much of a point in having
further named container registrations for the same type. It would just
make things more complicated. Mind that the name had already been
ignored before, just not explicitly.

[ChangeLog][QtQml] You can now use lists of value types in QML. For
example a property of type list<int> will hold a list of integers.

Task-number: QTBUG-82443
Change-Id: I7bee61cee3963dae5d231bf59f70b8012984371d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-28 15:03:00 +01:00
Maximilian Goldstein 2c7ba307f7 qmllint: Do not warn about required properties with root aliases
Previously we warned about required properties that had a root level
alias. This pattern might be used to expose a nested required property
to the component's User though, so this change makes sure we do not warn
about the property being unset anymore.

Fixes: QTBUG-99693
Change-Id: I3ac7bcfe49b67ffb1b04373bd2770f465bd228f8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-27 13:08:09 +01:00
Kai Köhne f3e4ecfbff Use up-to date LGPL license header
Remove usages of outdated LGPL3 header that references LICENSES.LGPLv3
instead of LICENSES.LGPL3.

See also 5d4679289b for a similar commit in the past.

Pick-to: 6.3
Change-Id: Icbe5eea7bb7b9c5d46cdd56fa3b177d2e22a5fa9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-27 07:33:08 +00:00
Andrei Golubev 97123dbe67 qmltc: Rename CMake command's argument FILES -> QML_FILES
This way we make it consistent with qt_add_qml_module()

Fixes: QTBUG-100214
Pick-to: 6.3
Change-Id: I9f38a8ba3dec978ccdf4ea937ff662ae2449e582
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-26 19:23:16 +01:00
Andrei Golubev f03f6eec9a Prototype private property access in tst_qmltc_manual
In theory, private properties could be supported in the compilers
through the QMetaProperty. Since we already know each C++ property's
index (and QML properties cannot be private), we can use that index
for a fast-ish QMetaProperty lookup. QMetaProperty itself has read and
write methods, which should be sufficient for all the use cases:
* read a value
* write a value
* create a binding
In fact, binding creation on non-grouped private properties is already
supported (or almost supported) since bindings already rely on
QMetaProperty information.

As a downside, QMetaProperty (even without name lookup) is still an
overkill compared to
static_cast<ClassPrivate *>(QObjectPrivate::get(this)) and then calling
READ/WRITE/etc. of a property directly

Task-number: QTBUG-91956
Change-Id: If77d2783ac161cb9bdd0bd9d0b397fe88e9c471d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-26 08:10:08 +01:00
Ulf Hermann d6eaa70859 QmlCompiler: Rename include -> import
We do not include things in QML, we import them. Also, the -i option
preferably imports from qmldir files, not from qmltypes.

Change-Id: Id4c5b3b774516526dfe80afa1c850bcccd6b2b4d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-25 23:55:27 +01:00
Ulf Hermann 0aa681c78b tst_qmlcachegen: Output some diagnostics on failures
Change-Id: I43b407670916ff53faab34194617d54217c0da27
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-25 23:55:27 +01:00
Ulf Hermann 5a908de8b7 Allow custom named value types in QML
You can now add your own, lower-case named, value types to your own
module, and use them in QML. Previously the names had been ignored, but
now you can actually declare properties using the value types.

The QtQuick value types are now handled exactly this way, and their
special casing at compile time is removed.

[ChangeLog][QML][Important Behavior Changes] You can now add your own
value types to QML modules. This works exactly like the registration of
object types, just with Q_GADGET instead of QObject/Q_OBJECT. In turn,
the QtQuick value types are only available from QtQuick now. Previously
you could declare unusable properties of QtQuick value types when only
importing QtQml. This is not possible anymore.

Task-number: QTBUG-82443
Change-Id: I5b2e867141244531cb13d789678fb7e06a6e41e7
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-25 23:55:27 +01:00
Ulf Hermann 6728913542 Add missing dependencies to tst_qmlcppcodegen
Pick-to: 6.3
Change-Id: Ifb5af14faa8229d4f7025d275147044629f4f2cb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-25 23:55:27 +01:00
Pasi Petäjäjärvi 3199567e96 QML: Host only tests
Pick-to: 6.2 6.3
Change-Id: I7c0f65868258bd706d9c55022d3546f2b1cb771a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-01-25 02:14:56 +02:00