Commit Graph

3671 Commits

Author SHA1 Message Date
Ulf Hermann c2805daaa5 QmlCompiler: Recognize script types when looking up members
If you import a module with a prefix, you can use its scripts as members
of that prefix.

Pick-to: 6.4
Fixes: QTBUG-104701
Change-Id: I35f79005ea793f501e782e748f7ad5badd3d75ef
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-22 21:30:16 +02:00
Ulf Hermann 1969a10821 QmlCompiler: Support conversions between QString and QByteArray
Pick-to: 6.4
Fixes: QTBUG-104702
Change-Id: I80d3a28e17751d440ec4bea4c7be0d09c935fa19
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-22 21:30:12 +02:00
Andrei Golubev 8d0adee3b3 qqmltypecompiler: align runtime function table order to qmlcachegen
When we write runtime functions to compilation unit at run time, the
order of the functions in the unit (often) differs from the order of
functions in the unit produced ahead of time by qmlcachegen and friends.
Additionally, the order also differs from what qmltc expects (and
qmlcompiler library in general)

Fix the order by simplifying the procedure of JS code generation when
we create the compilation unit at run time: new logic just goes over
the objects in the document linearly, instead of relying on bindings
(which are known to be out of order w.r.t. AST)

Change-Id: I4070b9d061f03c4c76d03120654ad3f30725493a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-22 16:38:42 +02:00
Ulf Hermann e4f4e7341f QmlModels: Fix context and extra object handling
If we have a bound context, we still need to record the information that
the object's context belongs to a delegate. For this purpose we have
the extra object. Even when we create the object in the component's
creation context, the object creator still produces a private internal
context for each object. We unconditionally attach the extra object to
that one, and check the whole context hierarchy for extra objects.

As we now record the creation context for model items incubated from
bound components, we need to make sure not to (re)set its context object
and not to forcibly invalidate it. We have QQmlRefPointer::reset() for
that anyway.

As a drive-by we also assert that the object ref count doesn't overflow,
as that has happened during testing.

Pick-to: 6.4
Fixes: QTBUG-104884
Change-Id: I836916c63656124a0f9d7b04902debba59b9f3a3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-21 13:19:04 +02:00
Ulf Hermann e97f8cabc8 QmlCompiler: Implement Math.pow()
Also, add missing positive infinity to test data.

Pick-to: 6.4
Fixes: QTBUG-104745
Change-Id: I958aca672cca8cc83c540ed3ea75b08e70eb90fd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-21 13:19:04 +02:00
Ulf Hermann 1879c8a6ba QmlCompiler: Extend all sequence types with JS Array
QV4::SequenceObject and QV4::QmlListWrapper both implement all the array
methods. Therefore we can safely state this.

Fixes: QTBUG-104706
Change-Id: I82c40f161b49463a9399a8bc58d741c7c4a1d5fe
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-19 10:52:39 +02:00
Ulf Hermann ef057772c4 Fix array-like methods on V4 sequences
We need to properly convert value type lists on assignment and we need
to add the "length" property to the own properties. Furthermore, the V4
sequence methods were confused about integer type ranges. We teach
them about qsizetype, properly range check everything, and drop the
artificial limitation to INT_MAX.

Pick-to: 6.4
Task-number: QTBUG-82443
Change-Id: Ie5af1130c9e78e412c171e6fa26a28a6a7a5d498
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-19 10:52:31 +02:00
Ivan Solovev b335d8311f tst_qqmlfileselector::applicationEngineTest: do not use deprecated API
... use QQmlApplicationEngine::setExtraFileSelectors() instead.

We also need to rework the rest of the test, so that engine is actually
initialized and the new selector is applied.

Task-number: QTBUG-104950
Pick-to: 6.4 6.3 6.2
Change-Id: I994ca01c3fe1acef63da01f6d7d4e443d1f28f91
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-19 10:39:45 +02:00
JiDe Zhang 90773dfbf1 Add 'override' keyword to fix build warnings
Change-Id: I8bd51da4ad27c97be78c708af33d6b1e4c1ca957
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-19 16:34:23 +08:00
Fabian Kosmale e814ff1e86 QML: Support negative values in enums
[ChangeLog][QML] It is now possible to use negative integers as values
for QML enum declarations.

Change-Id: I321ad45ab41d5ef23d37d202a384d40e2e1e239d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-19 10:02:03 +02:00
Ulf Hermann f508c48e03 Add test to verify we can read through a bindable-only property
Task-number: QTBUG-97249
Change-Id: I7a9dcaf983ec6c7d0099ab5a9f61b301a502af27
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-18 13:53:30 +02:00
Ulf Hermann 7e4b179430 Implement array methods for QQmlListProperty
The test revealed that the fill() method of JS arrays did not properly
range-check its parameters. Fix that, too.

[ChangeLog][QtQml][Important Behavior Changes] QQmlListProperty behaves
like a JavaScript Array now. You can use map(), reduce(), forEach() etc
on it. This also includes a slight change of behavior to the push()
method. push() now returns the new list length, and it checks the length
to not exceed UINT_MAX.

Task-number: QTBUG-58831
Fixes: QTBUG-49613
Fixes: QTBUG-99041
Change-Id: Ia64d73fb704449c280fbbc7ddcf20f4698c82e09
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2022-07-16 09:21:27 +02:00
Leticia Valladares c61075d2e0 UrlObject: Add colon after scheme
This change adds a colon after scheme in methods 'setProtocol' and
'setUrl' on its protocol line. Likewise, this includes a test called
'colonAfterProtocol' to check if colons were correctly added by using
different schemes: ftp, http and https, or if colons were removed when
setting the scheme (i.e. from protocol 'ftp:', 'ftp:http:' or 'ftp:::'
to 'ftp').

Fixes: QTBUG-103746
Change-Id: I8f847bedd23e476e0ae7901a2f3f3963da3ca04d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-14 23:59:21 +02:00
Sami Shalayel 111225b6c4 Support value type lists in qmltc
Generate list of values in qmltc when possible, by using QList<T>
instead of QQmlListProperty<T>, e.g., when T is an int or a QColor..

Fixes: QTBUG-100313
Change-Id: Ifd84cbb550437854fb156a295435240cef446e61
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-13 13:29:49 +02:00
Fabian Kosmale 8122dcea13 QML engine: Let string match QUrl during overload resolution
If an overload set contains a function with a QUrl parameter, and we
pass in a string, that would have resulted in the worst-possible score
of 10 for that function.

Given that URLs are often provided as strings in QML for convenience
(instead of using e.g. Qt.url), that is arguably a bad idea.
Starting from this commit, they'll get a score of 6: QJsonValue still
wins (to minimize the risk of breaking existing overload sets), but we
no longer claim that there is no match at all for such a parameter.

Change-Id: Ic0faa0029c9d5f14aff143cbd7fd4859d9ac2b2a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-12 20:17:15 +02:00
Ulf Hermann 2b138dd517 Unblacklist tst_qqmlxmlhttprequest
The test hasn't failed anymore for half a year.

Fixes: QTBUG-99149
Change-Id: Ie9ebef0f92f3b9a02426184295da7c18469f5669
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-12 12:43:37 +02:00
Ulf Hermann 2885d0c924 Unblacklist tst_qsequentialanimationgroupjob
The last time it BFAILED was in March 2022.

Fixes: QTBUG-99174
Fixes: QTBUG-99175
Change-Id: I0b2664bcfac390cc4ee08ff2be1813feff711688
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-12 12:43:30 +02:00
Ulf Hermann 873bdb3146 Disable debugger tests on macOS/x86_64
They run into a hard to reproduce deadlock in the CI. In turn re-enable
tst_qqmljdebugjs for macOS/arm as there it doesn't happen.

Pick-to: 6.2 6.3 6.4
Task-number: QTBUG-102984
Task-number: QTBUG-101678
Change-Id: I17d483b7c44b36d17cfc2f0f31fcccd30cd4548a
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-07-11 17:23:24 +02:00
Ulf Hermann e19328fb0f QmlCompiler: Allow storeNameSloppy to reset a property
We should not convert from undefined on storeNameSloppy. The reset is
intentional.

Task-number: QTBUG-104508
Change-Id: Iede88fe6331dd173c9e8ea0ec4200df2b8bd30eb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-11 13:37:26 +02:00
Andrei Golubev b9cae6a90f qmltc: Make Component.onCompleted compilation less special
Use the existing compilation machinery to handle attached Component
signals

Task-number: QTBUG-91956
Pick-to: 6.4
Change-Id: I271e3c50b61a8e38d9bb601768d871bf977f365a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-09 17:12:06 +02:00
Ulf Hermann 4621f79c41 Unblacklist tst_qmltyperegistrar
The failure was specific to the qmake build, which doesn't exist
anymore.

Fixes: QTBUG-88381
Change-Id: I5c128d958e88af54b9d216dc01aaa30ecf9d58fa
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-07-08 18:51:19 +00:00
Ulf Hermann f83b4bc1dc Unblacklist tst_qmlformat
The last time this has BFAILED was in February 2022.

Fixes: QTBUG-98494
Change-Id: Ie97dcd702eb79ef598d2cf79a417d1b311521599
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-07-08 20:51:08 +02:00
Lucie Gérard 5a7b716474 Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I72c89a98c42bbc9234d8495e9e503bec81d11037
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-08 10:41:06 +02:00
Maximilian Goldstein bd38bd435a qmljscompiler: Replace categories with more specific warning ids
This change replaces a lot of generic category names with several warning
ids to replace them.

Change-Id: I9b13b931e7ed3d56b71d6292a6a77bec69647ffd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-08 10:28:50 +02:00
Ulf Hermann a1aa9f8d42 Pass the "reset" attribute from metatypes through qmltypes
We need it when deciding what to do with an undefined value assigned to
a property.

Task-number: QTBUG-104508
Change-Id: I621d531040fe423e11372eea8903d69c93f4ecd6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-07 20:04:12 +02:00
Ulf Hermann 38fdf2717d QmlCompiler: Handle trivial signal handler constructions
If the signal handler does nothing but return a closure, we have to
compile the closure using the same signature as the outer signal
handler.

In order for this to work, we also have to detect unresolved argument
types for signal handlers. Those are just as bad as unresolved argument
types for other functions.

Fixes: QTBUG-101531
Change-Id: Idb5b3994809d91a4b4ce936282685435eb75e670
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-07 19:33:39 +02:00
Ulf Hermann 3f3e961a5a QmlCompiler: Allow wrapping enums into int
This is what we do internally in the QML engine.

Pick-to: 6.4
Fixes: QTBUG-104683
Change-Id: I2f8712cb2cdc56b6c483500627fd8a218edbad81
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-07 19:33:27 +02:00
Ulf Hermann 0e48d9d938 QQmlValueTypeWrapper: readReferenceValue in virtualGetOwnProperty
Otherwise we may end up with a nullptr gadget.

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-104803
Change-Id: Ia0c3741fdf0214f0c3d4b352006442747f635f5c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-07 19:33:18 +02:00
Ulf Hermann 1d93816ac2 tst_qqmllanguage: Adjust to QMetaTypeInterface no longer being mutable
We must not create a const QMetaTypeInterface variable, as we are going
to modify it shortly after by calling id on it.
On the other hand we can make it Q_CONSTINIT, as metaTypeForNamespace is
constexpr.

Adapts to c474825945a418ae9d8494c80b6803b6279e0cf5 in qtbase.
Amends commit 5db7944de8.

Change-Id: Idbf044b676b6f3859198aeefcb0322e9e9461e5c
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-06 21:28:27 +02:00
Ulf Hermann 8dc33d3672 QmlCompiler: Don't crash on unknown list value types
Pick-to: 6.4
Fixes: QTBUG-104743
Change-Id: I551b21498bb746acf05be525dbcb72a74f816c04
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-06 21:28:05 +02:00
Ulf Hermann 8056df3284 QML: Re-add the Qt namespace enums to the Qt object
They were replaced with an extension to the Qt singleton in Qt6.
However, the singleton is only available when QtQml is imported.
We can easily provide the enums using the metaobject of the Qt
namespace.

Pick-to: 6.4
Change-Id: I5f58d30c749c0cb9e531df180a5cbe75c92e1aa6
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-07-05 23:29:37 +02:00
Ulf Hermann b4663aa5b6 Implement virtualOwnPropertyKeys for QQmlTypeWrapper
Fixes: QTBUG-82591
Change-Id: I3cc39f00b5384065c9f2f226e64dee9fa3fcddac
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2022-07-05 23:29:37 +02:00
Ulf Hermann af335a89bd QmlCompiler: Initialize registers with undefined where necessary
If we read the initial state of a register, we need to make sure it
actually exists at that point. Uninitialized variables are implicitly
undefined in JavaScript.

Pick-to: 6.4
Task-number: QTBUG-104687
Change-Id: Ide4fe429b10ec28dcf267e7d34c6316355b16baa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-05 19:50:28 +02:00
Ulf Hermann 7d36ec0bd9 QmlCompiler: Don't push type conversions back into the engine
In many cases we can generate better code for type conversions.
Furthermore, the engine only does QMetaType::convert(). This misses a
lot of conversions we do in other places.

Pick-to: 6.4
Change-Id: I1526ec327d189420885f6a7385f6cc1c2c94b19e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-05 19:50:24 +02:00
Ulf Hermann 4639607036 QmlCompiler: Really fix writing into argument values
Arguments are now treated as registers "written" at the beginning of
the first basic block. By modeling them this way, we can avoid all the
complicated logic on whether to use a local or the arguments array when
accessing any particular one of them. Furthermore, we can detect whether
they are overwritten or not. If they are not overwritten, we can
initialize them as a const reference into the arguments array. This way
we save a copy.

Treating the arguments as generic registers causes the basic blocks pass
to aggressively adjust their types, pushing some conversions back into
the QML engine. This is good. Unused arguments become void, for example,
and don't have to be passed at all. However, we also need a special case
for QJSPrimitiveValue arguments now.

Pick-to: 6.4
Fixes: QTBUG-104462
Change-Id: I994bea0929bd508aa41db58dee4a7f12cd20f053
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2022-07-05 19:50:19 +02:00
Ulf Hermann 5e4a1738b0 QmlCompiler: Fix register propagation in basic blocks pass
a, We were recording too many jump origins and targets. That messed up
   the basic blocks ordering logic.
b, In the presence of backward jumps, we need to revisit earlier basic
   blocks if additional writes are discovered. Otherwise the type
   adjustment will optimize "dead" type conversions out.

Pick-to: 6.4
Fixes: QTBUG-104665
Change-Id: I7219f85625761817ae4f63582d80d247a85df73b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-05 19:50:15 +02:00
Mitch Curtis 234afb5502 Add convenience API for making QQmlDataTest-based tests fail on warnings
After this patch, if a QQmlDataTest-derived class passes
FailOnWarningsPolicy::FailOnWarnings to the base constructor, any
non-empty warning encountered by that test will result in a test
failure.

This avoids the need to duplicate the catch-all regex in tests that
want to fail on warnings.

The goal is to gradually enable failure-on-warnings over time.

Leave comments and explicitly pass DoNotFailOnWarnings for tests that
should never fail on warnings.

Task-number: QTBUG-98718
Pick-to: 6.2 6.3 6.4
Change-Id: I4b647d93a0f28ac891c4bdb19ef74569f2918e8f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-05 14:34:37 +08:00
Andrei Golubev 79f9e22ef7 Do not store instantiation errors in QQmlComponent
QQmlComponent::createWithInitialProperties() allows to pass non-existent
properties to create the object with. In this case, we still return a
valid pointer (pre-existing), however, the state of the component is
affected: there are errors internally that fail repeated calls even with
valid properties specified. Fix this, aligning to the behavior of
QQmlComponent::createObject() which is a QML counterpart of the same
function (to a degree)

Additionally, make required properties warnings also not break the
component state: if a required property is not set, we return nullptr
instead of object. The error state is affected but it gets cleaned
on the next creation call, allowing one to set the missing required
properties

Unify the logic (with slight deviations) between create() (the
non-incubator-accepting version), createWithInitialProperties() and
createObject() as all they all should do roughly equivalent things

[ChangeLog][QQmlComponent][Important Behavior Changes] Setting properties
via createWithInitialProperties() and setInitialProperties() no longer
affects the QQmlComponent's error state unless there are unset required
properties. A warning is issued when a property could not be set.

Fixes: QTBUG-101439
Change-Id: I814c00bc3715d7a54004c3fcd0af6ee6d50b0726
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-30 20:26:21 +02:00
Andrei Golubev d968b23671 qmltc: Ensure properties with MEMBER can be read and written
Pick-to: 6.4
Task-number: QTBUG-91956
Change-Id: I980089ed7e4991de7bf7429722caf7351d9e79b4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-30 20:26:21 +02:00
Maximilian Goldstein a9038a6cc6 QQmlJSLogger: Switch to an ID based system
This change makes qmljslogger use an ID based system for categorizing
logging entries instead of using an enum. This allows plugins to
register their own logging categories after the fact.

It's also necessary for us to later show the warning ID when
printing warnings and for creating documentation for each ID entry.

Currently not every ID maps cleanly to only one type of warning,
this has to be cleaned up in a follow-up change.

Task-number: QTBUG-103453
Change-Id: I4cac6be7ca165b938e0ea032d077823bf17baf75
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-30 11:23:36 +02:00
Fabian Kosmale 10fa5f6bfe Make callLater an invokable using QQmlV4Function
While we really do not like QQmlV4Function, it is still better than
creating an invokable property to define a method.
This way, qmllint at least knows that it is a function.

Fixes: QTBUG-104574
Change-Id: I8342c96163f6a79ab6dd92116407f64b5e156760
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-30 11:19:23 +02:00
Sami Shalayel 33aa69529c Fix debugger crash on attach
The debugger treated QQmlGadgetPtrWrapper like normal QObjects,
which means that their metacalls where done incorrectly.
The meta system saw the QQmlGadgetPtrWrapper's metaobject,
which is actually the wrapped type, and produced a garbage
QObject* by reinterpret_casting the wrapper as the wrapped type.
The debugger was changed to recognize gadgets and to call
the read/write/resetOnGadget() methods instead of calling
QMetaProperty.read/write/reset().
Added a test with the qml example that was making the
application crash when a qml debugger was attached to it.

Fixes: QTBUG-104379
Change-Id: I7c1138fc44ee78137386dcd7da145bbaab574afc
Pick-to: 6.3 6.4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-30 11:13:54 +02:00
Andrei Golubev 9a8948f9d1 qmltc: Use correct output C++ file names within a module
Due to custom basenames in CMake qmltc can create non-default file names
that contain the generated C++. This would cause troubles when locally
importing such a custom-marked QML file from the same module. Resolve
this by introducing a qrc-based mapping from source file name to C++
header file that the generated code would be put into

Use the mapping information inside QmltcVisitor so that imported types
are properly set

Doing so, with some additional fixes around file paths collection,
allows to get rid of the prototype code completely

Fixes: QTBUG-104094
Pick-to: 6.4
Change-Id: I6a54774addf303449f35915df501ab3f47470c44
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-29 17:00:12 +02:00
Maximilian Goldstein a6b05ea90e qqmljstypepropagator: Use object that is being attached to as context
Previously the read/writeContext of an attached property was being
set by the scope the attached object was being accessed in.

This is now set by the actual object the attached property belongs to
instead.

Task-number: QTBUG-104209
Change-Id: I6617a88fab9a88b9f69f149df9e12e0df0a4bcbc
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-29 17:00:12 +02:00
Ulf Hermann 0e3d42c840 QmlCompiler: Don't generate invalid code for storing undefined
We don't actually have to store the retrieved value if it's not
storable.

Pick-to: 6.4
Fixes: QTBUG-104508
Change-Id: Ib091eabf4f4034a577b94e0d5761c5307815599e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-29 13:26:07 +02:00
Alexandru Croitor 83869e75d1 CMake: Add autogen dependency to fix top-level static builds
Amends d26675105b

Fixes: QTBUG-104555
Change-Id: Icddcadfc15b4172fcee457fa4de2c6522bf95531
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-28 14:35:10 +02:00
Samuli Piippo c839f57e54 CMake: add dependency to QmlIntegration in qmlsplitlib test
Amend c3503e19e7 and add dependency
to QmlIntegration to fix:

| /home/qt/work/build/build/tmp/work/core2-32-poky-linux/qtdeclarative/6.5.0-r0/git/tests/auto/qml/qmlsplitlib/lib.h:8:10: fatal error: QtQmlIntegration/qqmlintegration.h: No such file or directory
|     8 | #include <QtQmlIntegration/qqmlintegration.h>
|       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: I591b6cc4d0d2aefc20f243a0a5b9f7780b5e47bd
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-28 08:01:55 +03:00
Ulf Hermann 7230508c3b QmlCompiler: Add missing parentheses to in-place arithmetic operations
Pick-to: 6.4
Fixes: QTBUG-104512
Change-Id: I3d592eeda5cefd9e9805b1811b37bebec5d6fc9c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-28 01:52:43 +02:00
Sami Shalayel 3ab408da5d Ensure QmlForeign attribute does not leak into derived types in C++
Use the QmlTypeHasMarker helper struct to disable Qml type attributes
for types that are not marked with the corresponding macros but merely
inherit them from a superclass.

This fixes the use of the QML_FOREIGN macro, other commits will follow
for the other attributes.

[ChangeLog][QtQml][Important Behavior Changes] Classes decorated with the QML_FOREIGN macro will
stop passing on the QML_FOREIGN functionality to their subclasses.

Task-number: QTBUG-104179
Change-Id: Ib394e8568bca29aff10561557c1af3574b405d2a
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-27 13:16:07 +02:00
Sami Shalayel 42e3acaf9a Ensure QmlSingleton attribute does not leak into derived types in C++
Use the QmlTypeHasMarker helper struct to disable Qml type attributes
for types that are not marked with the corresponding macros but merely
inherit them from a superclass.

This fixes the use of the QML_SINGLETON macro, other commits will follow
for the other attributes.

[ChangeLog][QtQml][Important Behavior Changes] Classes decorated with the QML_SINGLETON macro will
stop passing on the QML_SINGLETON functionality to their subclasses.

Task-number: QTBUG-104178
Change-Id: I3adf3e11b734b64ea3c3d2540d1e33963e979a04
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-27 13:16:02 +02:00
Sami Shalayel cdcc41c8c1 Ensure QmlAttached attribute does not leak into derived types in C++
Use the QmlTypeHasMarker helper struct to disable Qml type attributes
for types that are not marked with the corresponding macros but merely
inherit them from a superclass.

This fixes the use of the QML_ATTACHED macro, other commits will follow
for the other attributes.
[ChangeLog][QtQml][Important Behavior Changes]
Attached properties are only accessible from classes directly decorated
with the QML_ATTACHED macro. Derived classes cannot inherit attached
properties. Classes attached using the old way (via QQmlTypeInfo) are
unchanged.

Task-number: QTBUG-104177
Change-Id: Ia5393101ba17049bc0917e32668abc69a5ffe9d7
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-06-27 13:15:59 +02:00
Ulf Hermann a864561468 QmlCompiler: Inline String.arg() into generated code
This way we can compile common translation expressions with .arg(a).

Task-number: QTBUG-101387
Change-Id: I89cdef48b63886684569c5b587ea69c937085b62
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-24 22:17:17 +02:00
Ulf Hermann 23fdccf7f3 QmlCompiler: Inline translation methods
We hardcode them into QQmlJSTypePropagator and QQmlJSCodegenerator for
now. This is OK for builtins.

Task-number: QTBUG-101387
Change-Id: Ifab46083b3a782f009859ce969c283d5bb2b4e8b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-24 14:47:58 +02:00
Ulf Hermann 1b6069798a Allow resetting value type properties
Fixes: QTBUG-60909
Change-Id: I589c0b30cead134f746def2ffc853ff43d2598e0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-24 14:47:46 +02:00
Marc Mutz 5ba6e17790 tst_QQmlPropertyCache: work around name chance in moc-generated code
The offsetsAndSize member was renamed to offsetsAndSize_s_ recently.
Detect the name change and use one or the other instead of failing.

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-104523
Change-Id: Ica16a91577fd1d20352e2c8136453432acbbc8b0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-23 07:36:17 +00:00
Ulf Hermann 6aad465f08 Introduce a sane resource path to qt_add_qml_module
Since "/qt" is reserved, we can use "/qt/qml" as the default path for
user QML modules.

[ChangeLog][QtQml] The AUTO_RESOURCE_PREFIX option was added to
qt_add_qml_module(). It places your QML modules in the otherwise
reserved resource directory /qt/qml. This directory is also added to the
default QML import path. By using it you don't have to specify custom
import paths anymore. Specifying neither AUTO_RESOURCE_PREFIX nor an
explicit RESOURCE_PREFIX will generate a warning now because such QML
modules are likely invisible in the resource file system.

Fixes: QTBUG-95145
Fixes: QTBUG-103452
Change-Id: Ie27dec5cbf34ea06258d55c659d202cdd61e54b2
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-23 09:35:57 +02:00
Ulf Hermann 6a0ab2e8aa QmlCompiler: Fix miscompilation if arguments are overwritten
In that case we need to allocate extra registers. We already did so
before, but we wouldn't use the registers afterwards.

This works nicely in 6.4 because we have a separate type for each store
operation. Therefore, the original function argument (being of a
different "type") won't be found in the list of local registers. Access
to it falls back on the actual arguments array. Only once we've stored
something into the register that mirrors the argument we can retrieve
it.

Pick-to: 6.4
Fixes: QTBUG-104462
Change-Id: Ibb0315cd2f8a8e4106d39fff88a6097b1623eb48
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-23 09:35:57 +02:00
Ulf Hermann 87f9847144 QmlCompiler: Properly annotate ThrowException instruction
It doesn't write the accumulator, but it does read it. Generating code
for throwing exceptions reveals that we have to default-construct the
return type rather than converting from undefined/void when throwing an
exception.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104447
Change-Id: I0a725679d8ecb7e87bb20528033097bc0c3c7bb6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-23 09:35:56 +02:00
Fabian Kosmale 9d22088d93 Remove warning about inability to defer properties
It is generally not actionalbe. In QQC2, we mark properties as deferred,
so that users can replace them with their own custom elements.
We however really don't care about the replacement not being deferrable,
as it will be needed in any case (e.g., Control will create its
contentItem and background in componentComplete if they do not exist
yet). Thus, there is zero gain in ensuring that the replacement is
deferrable.
There are cases where this is not the case: You might want to create a
whole new style, and in turn allow users to override elements there. Or
there might be an item where deferring indeed makes sense.

However, we cannot distinguish those cases so far, and as long as that
is the case, we should not confuse users by complaining about a concept
which is mostly engine internal (the only public documentation about
deferred properties is
https://doc.qt.io/qt-6/qtquickcontrols2-customize.html#considerations-for-custom-styles
and that does not mention the word deferred), where fixing the warning
might not even given them any benefit.

Checking that our standard controls do not prevent deferring is better
checked in tst_sanity statically via qmllint.

Pick-to: 6.4
Fixes: QTBUG-98964
Change-Id: I030e2a2c2a1d99c9cc6cf0d892e0a1d17e048b6a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-06-23 04:48:50 +02:00
Maximilian Goldstein 842fe4dd27 QuickLintPlugin: Fix var property type checking
We accidentally checked the element type instead of the binding type.

Also added some more tests to make sure this doesn't happen again.

Fixes: QTBUG-104430
Change-Id: I5848b937b7bf4b15ad09adbe1d2a3941c4572fb5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-21 10:30:15 +02:00
Alexey Edelev bfc9e70632 Add autogen tools dependency to the tst_qmltyperegistrar_major_version_zeroplugin target
Amends: 9225723a31

Pick-to: 6.3 6.4
Task-number: QTBUG-104373
Change-Id: Ic6989db9c9339774e856ec8078c91a76667b992a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-21 00:21:53 +02:00
Maximilian Goldstein c0a01a72f0 qqmljsimportvisitor: Fix bindings on prefixed attached properties
Previously these would have not been created properly. This change fixes
this and adds some tests.

Fixes: QTBUG-104197
Pick-to: 6.2 6.4
Change-Id: I3d2d7d5a0e4019d9f7bd3496ea5762d4b7d680cd
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-20 11:58:04 +02:00
Sami Shalayel 222d92cdd7 Remove tst_qqmljsscope::qualifiedName as it blocks integration
Remove the test to allow integration to work again. A commit will
follow to repair and readd it.

Fixes: QTBUG-104079
Change-Id: I56fbcaee88bca5520da1b3d5ca2c3c47eb3c519a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-20 11:58:04 +02:00
Sami Shalayel d26675105b Reimplement tst_qqmljsscope::qualifiedName() to not block integration
Reimplement tst_qqmljsscope::qualifiedName() to test the versioning
on Qml elements that will never change their versioning information.
Before, this test was testing elements from QtQuick that were subject
to change with every Qt version.

Fixes: QTBUG-104079
Change-Id: I45c18d1a995b1a8aa99dd15d86dfbb26f5666545
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-20 11:58:04 +02:00
Sami Shalayel 69ba1eee9e qmltyperegistrar: Warn about duplicate exports
Warn when different types are exported under the same name and
revision.

Fixes: QTBUG-103189
Change-Id: I90258d5fdd7ab531f8093ed2ca871d40d0b68519
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-20 08:08:06 +02:00
Alexandru Croitor 9225723a31 Qml: Allow major version of module to be zero
If there is no QML.AddedInVersion then the component should be available
from version X.0, with X being the current version of the module.

Amends 464abaec05

Pick-to: 6.3 6.4
Fixes: QTBUG-104373
Change-Id: If30b66df384fe815c41d2a0b5ca7b034b9955956
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-18 08:13:20 +02:00
Ulf Hermann f3d9e9214b QML: Drop backup source code once we're done with it
If a component is done loading, we don't need the source code anymore.
Dropping it makes it possible to unmap any resources it may be part of.

Pick-to: 6.4
Fixes: QTBUG-86088
Change-Id: Id523fffb788b5ffa60cb1e7b777328c6648c2a88
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-17 21:12:47 +02:00
Maximilian Goldstein 7424756626 quicklintplugin: Ignore root components for certain attached properties
If the attached property can only be used in certain delegates and it's
used in a root component, there's no way of knowing whether or not it
will be used in a valid way, so don't warn about it.

Fixes: QTBUG-104209
Change-Id: I70593ca05473b38e341592fa8a117e0e92c651ec
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-17 21:12:47 +02:00
Maximilian Goldstein 50ce71ae72 QmlLintQuickPlugin: Warn about unexpected property binding types
Sometimes we use var or Item property types when we actually expect
some very specific types. We warn about these at runtime, let's also
warn in the linter.

Task-number: QTBUG-102859
Change-Id: I68c2bc8b2bf5097723a432d02d76f45651f4ef12
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-17 21:12:47 +02:00
Maximilian Goldstein 6d15a35e9c qqmljsimportvisitor: Fix relative paths being broken with resources
qrc cannot handle ".." in paths, so we need to clean our paths in order
to make relative directory imports work.

Fixes: QTBUG-103903
Change-Id: I31386728a7a20c30bd8c087dd3a1f2affc369cf4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-17 21:12:46 +02:00
Andrei Golubev 5b5010c52d Show QJSValue::toMap() is a valid input for createWithInitialProperties
Add a tst_qqmlcomponent test dealing with QJSEngine originated
dictionary converted into a QVariantMap. QQmlComponent should be able to
correctly handle such cases

Task-number: QTBUG-101440
Change-Id: I1550dbf28a1ae1eee5473914515f1bf46f8d788a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-15 09:43:01 +02:00
Ulf Hermann e18919d3f2 QmlCompiler: Check builtin type aliases after list resolution
This way we can determine that QList<qreal> is the same as
QList<double>.

Pick-to: 6.4
Fixes: QTBUG-104129
Change-Id: I96df19da1a613558b950aa6cee46159024c19cc9
Reviewed-by: Evgeniy Dushistov <dushistov@mail.ru>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2022-06-15 09:43:01 +02:00
Ulf Hermann fb3a81623a QmlCompiler: Reject conversions via QJSValue
Those are generally less efficient than what the interpreter would do,
they can have side effects, and they can throw exceptions. We don't want
to deal with any of that. Most of those implicit conversions have
explicit equivalents. For those that don't we can add them.

Pick-to: 6.2 6.4
Fixes: QTBUG-104010
Change-Id: I62898db92219386c94f2a6c9b56f6fb0b7578832
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-15 09:43:01 +02:00
Maximilian Goldstein c3503e19e7 tst_qmlsplitlib: Utilize qmlintegration.h
Now that we have split integration into a separate module, use that
instead.

Also fixes a warning about redefining QML_SINGLETON.

Change-Id: Iad54ac7815957222d64e96342e48bb9eb25be2c0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-15 09:43:00 +02:00
Fabian Kosmale 0d0b744371 tst_qqmlnotifier: Do not assume qfatal crashes the process
Because we run a test, we might have a handler for SIGABRT installed. If
qfatal uses SIGABRT to terminate the process, we will thus actually
handle it gracefully.
Instead, simply check that the process has terminated, and rely on the
output being available.
As we check for "FATAL" in the output, the exit status check was anyway
redundant before.

Fixes: QTBUG-104051
Change-Id: I062a592e97e717cd1a0d93f7913b492aa322296a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 27cc99809d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2022-06-13 10:01:21 +00:00
Ulf Hermann 602a9385cb Canonicalize showing QQuickView in tst_qqmltablemodel.cpp
The old pattern of waiting for window exposure or activation is error
prone. We have this nice abstraction now.

Change-Id: I82a585b5e89941533b910052becddeef9551dceb
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-06-11 16:00:28 +02:00
Lucie Gérard 0dc4fd240a Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-06-11 08:05:15 +02:00
Edward Welbourne b3940d0f9e Restore the QTime round-trip on macOS
The QLocalTime revolution has fixed this.

Pick-to: 6.4
Change-Id: Ieeb21b81bb0c7c8eb811310731e16a7a37b1b1f4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-10 17:20:06 +02:00
Edward Welbourne 1aae77c94d Fix missing null-check after component.create() call
MinGW got a crash in tst_qqmlqt::dateTimeConversion(), due to the test
neglecting to verify that component.create() had succeeeded, when
various plugins were missing.

Pick-to: 6.4
Change-Id: I6ed5df864b78c689f3c572875115e4eea14748ca
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-10 17:19:59 +02:00
Edward Welbourne 1e457e8cd3 Tidy up in tst_qqmllocale::numberOptions()
Split a long line, only emit an error message if there is one.

Also remove the QTimeZone include: a recent change eliminated the
dependence on it. (The #include should in any case have been #if'd on
feature timezone.)

Pick-to: 6.4
Change-Id: Id8208b39927c0324597d2008061c48958a7cbbdb
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-10 17:19:53 +02:00
Edward Welbourne 6670a8b09a Split two long lines for the sake of readability
It's easier to see which flags are being set this way.

Pick-to: 6.4
Change-Id: I5ed7e9bcedacde19cb751512d404a872981f6eb0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-10 17:19:48 +02:00
Edward Welbourne c9377cd649 Suppress ES-compiler warnings against the ES-262 test-suite
V4's ES-compiler warns about assorted variables in the ES-262
test-suite being used before declaration. We aren't about to fix that
test-suite, so the warnings are just noise to us. As there are many of
them, they overflow the QTestLib logger's -maxwarnings threshold,
causing actually relevant messages (like test failures) to be lost in
the output.

Install a trivial QLoggingCategory::CategoryFilter to filter out
warnings and debug for the qt.qml.compiler category (and all
sub-categories of it). Condition this on a define so that someone who
actually wants to see those warnings can turn them on.

Pick-to: 6.4
Change-Id: If7decc241b407e816f5d7979b32f31a9f614d30f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-10 17:19:42 +02:00
Edward Welbourne b85374f7c0 Make uninteresting JS-test output easier to ignore
The JS-tests produce so much output that it routinely surpasses the
maximum number of debug messages testlib is willing to produce, after
which it cuts off and we don't get to see the output of failing tests,
which we actually need to see.

Add a logging category, just for this test, and condition the boring
bits on this category being enabled. Those are all qCDebug()s, so
disable the category for debug by default. In the process, re-enable a
commented-out qDebug() by converting it to use the new logging
category (and fixing the bit-rot that it had suffered while commented
out).

This should mean any future Coin failures in this test are reported
more usefully. If seeing all the PASS lines is really important to
you, enable category "qt.v4.ecma262.tests" in your Qt logging options
and pass -maxwarnings with a huge value when you run the test.

Pick-to: 6.4
Change-Id: I8ba1f6575120fcef533ae756d31cc40635c13370
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-10 17:19:37 +02:00
Edward Welbourne dff02466a0 Use qtbase's new (private) QLocalTime for Date's UTC offsets
This puts all use of system time_t functions in one place, instead of
spreading it out. Its implementation improves on what was formerly
done in V4 Date's offset calculations, while simplifying them and
eliminating most of the #if-ery.

Add four more test-cases to tst_qqmlqt::dateTimeConversion(), based on
issues seen on MinGW, getting the time-zone wrong due to the failure
of localtime_r(); MinGW can use localtime_s, as QLocalTime now does.

Revised tst_qqmllocale::timeZoneUpdated()'s conditions. The
QEXPECT_FAIL()s have stopped triggering, at least on Darwin, and the
issue isn't that Date.timeZoneUpdated() wasn't working, it's that (now
only on Android and Windows) we don't have a way to set the system
time-zone referenced by the system functions that QLocalTime calls to
get time-zone offsets. Setting the TZ environment variable only works
on faithful POSIX implementations.

Pick-to: 6.4
Fixes: QTBUG-85149
Fixes: QTBUG-95993
Fixes: QTBUG-102971
Change-Id: I7bc983b9fd7167e3bab3db41dbc1c6f4a78665b9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-10 17:19:25 +02:00
Ulf Hermann 2a4ec96ae0 QmlCompiler: Don't retrieve metaobjects for value and sequence types
This is not valid QML, and the generated code crashes.

Pick-to: 6.2 6.4
Fixes: QTBUG-104092
Change-Id: If609acc2f2dc84a2e8f7c26d4d1b6c626f337cad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-10 14:41:49 +02:00
Ulf Hermann 8e69558f2f qmltyperegistrar: Parse value type lists
We need to generate isList properties for those, so that qmlcachegen and
qmllint can handle them.

Pick-to: 6.4
Fixes: QTBUG-104129
Change-Id: I7e632279a605694c2fd5f583c8a6dcf9968eb634
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-06-10 14:41:32 +02:00
Andrei Golubev d28f088371 Remember QML document context in each qmltc-generated object
There is an apparent problem in certain cases where using outer context
to fetch ids is invalid: the outer context is the *outermost* context,
meaning that if a type has a derived type in another QML document,
the derived type would place its own context as a QQmlData::outerContext

As a simpler solution, just remember the document's context in all the
objects within this document. This automatically works in derived types
since they appear in other documents with separate contexts

Pick-to: 6.4
Fixes: QTBUG-103956
Change-Id: I29420ff4962b485502d87b2d2ac2f89b9e0f5736
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2022-06-09 16:22:22 +02:00
Andrei Golubev bf7aaeda87 qmltc: Move from QmlIR::Binding to QQmlJSMetaPropertyBinding
This symbolizes the last piece of QmlIR dependency that qmltc has.
We do still have some implicit dependencies on QmlIR, though, but
that should go way once the remaining prototype code's logic is
migrated to QmltcVisitor, QQmlJSScope and friends. This, however,
is not attempted here as the patch itself is rather large

In the process of switching to QQmlJSMetaPropertyBinding, observe
and fix issues in QmltcVisitor and surroundings

Pick-to: 6.4
Change-Id: I752b68a7f57baf354de16dc0bb466a3f693a4e49
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-06-09 09:12:28 +02:00
Andrei Golubev 99178a947c QmlCompiler: Fix script indices calculation
The logic is misbehaving on multiple occasions. For instance,
same-named signal handlers in different scopes and script bindings
inside array scopes were wrongly handled. Fix that by revising
the mechanism of inner function computation

As a drive by, fix parseLiteralOrScriptBinding() to distinguish
translation bindings from script bindings (they are vitally
different now)

Extend the script calculation test in tst_qqmljsscope to cover
the findings

Pick-to: 6.4
Change-Id: Ic4cf0a4539f0d714a416b61f4635eb6494e89922
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-06-09 09:12:14 +02:00
Andrei Golubev 6ced46e422 Rename tst_qmltc_{no}diskcache data folder to QmltcTests
Follow the policy of "good" QML modules where the module would reside
in a folder named the same way as the module URI

Somehow this is still not enough to remove an explicit
"-i <own qmldir>" workaround in qmltc compilation command

Change-Id: If1725ec03baf3690bb6cb8fc7876b082a155eaa2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-03 08:46:10 +02:00
Ulf Hermann 8ea9646019 QmlCompiler: Don't crash when trying to resolve null list types
If the element type is unknown the list type is also unknown. This will
happen if we cannot resolve the type.

Fixes: QTBUG-103920
Change-Id: If1b05d99a1e64961981b5adb3974a51c11e776d2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-02 10:07:40 +02:00
Andrei Golubev e5251efe97 Set bindings on QQmlJSScope after AST traversal
We can get into situations when binding creation is problematic
due to the relevant scopes being yet unresolved. In particular,
this happens when processing attached/group properties script
bindings

Avoid having this situation by postponing the actual binding
setting until after the relavant scopes are resolved (mainly,
the binding owner). However, do relevant AST order dependent
operations beforehand to avoid accidental errors

This commit amends 25098b7a4f

Fixes: QTBUG-103897
Change-Id: I671955dbe321d03e5f1ab9891cc79dc0a936deda
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-02 10:07:40 +02:00
Andrei Golubev 87053c5422 Inherit base type access semantics in QQmlJSScopes
Group scopes may be value types so they require access semantics
different from a default value

Ordinary scopes and attached scopes seem unaffected, only groups
are thus covered with an extra logic

Change-Id: Ia9012548a602ca7ca07296491d27a295f4455f91
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-02 10:07:40 +02:00
Andrei Golubev 26179e6937 Address extension types in qmltc
Whenever working with properties (reading, writing, aliasing, etc.)
of the type that has extensions, prefer the same-named properties
from extension objects over type-owned properties (this is the internal
QML mechanism)

To achieve that, we need to query the extension object:
* for Q_GADGETs use a dummy model of assuming we can cast the object
  to the extension type and use that
* for Q_OBJECTs use a qmlExtendedObject() with additional logic of
  figuring out which extension should be picked in each specific case

Create QQmlProxyMetaObject via a custom dynamic meta object API for
qmltc-compiled objects that are derived from base types with
extensions

Task-number: QTBUG-91956
Change-Id: I5e783768ae2abdb9dddf894de7e79960244352bd
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-02 10:07:39 +02:00
Andrei Golubev b85ac05e4a Document that QML_EXTENDED properties are practically FINAL
This is de-facto how it always was before
ff0b9ec6bf. As we plan to revert back to
the "original" behavior, document the FINALity of the properties so that
users know how it behaves (and we could not be held responsible for this
mess)

Change-Id: I4afed215fd66875821b7ce8d824b81782388324b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-02 10:07:39 +02:00
Andrei Golubev e353639d63 tst_qqmllanguage: Test extended group property case
Task-number: QTBUG-103881
Change-Id: Id5e0925f479ee638cc4db7fad18cc6d951b07f98
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-02 10:07:39 +02:00
Ulf Hermann e3e8008ec3 Allow retrieval of sequences from QJSValue
As we can store sequence types in QJSValue, we should be able to
retrieve them, too.

Move the declaration of the QV4::Sequence struct into a header to make
it less of a hassle to identify sequences.

Change-Id: I3e45bfe193c669107f90cd6c502765c0c9f60fb0
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-02 02:42:51 +02:00
Andrei Golubev 86fae5664c Remove qmltc compilation command in favor of qt_add_qml_module()
[ChangeLog][CMake] The qmltc compilation functionality provided by
qt6_target_compile_qml_to_cpp() is merged into qt6_add_qml_module()
command and is available through ENABLE_TYPE_COMPILER argument. The
qt6_target_compile_qml_to_cpp() function does nothing and is left
only to highlight that users must migrate away from it.

Fixes: QTBUG-100215
Change-Id: Ie7d6b82564dff86176194fce35039ba0d93c0977
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-31 17:23:09 +02:00
Jani Heikkinen 6f9fbc8fef Revert "Revise QQmlProxyMetaObject and extension chain creation"
This reverts commit ff0b9ec6bf.

Reason for revert: QTBUG-103881

Change-Id: I7e333ec854e81fb06f1f84b77125edc78bb181e6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-05-31 11:09:22 +00:00
Ulf Hermann 29e2c7b414 QQmlDebugProcess: Crash if we cannot kill the debuggee
If the debuggee somehow manages to ignore our kill signal, the QProcess
dtor will hang. Let's rather crash in this case, so that we see when it
happens.

Task-number: QTBUG-101678
Change-Id: Idc72412925244acfdb1dfdeec07369d5fb271080
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-31 12:55:00 +02:00