Commit Graph

6572 Commits

Author SHA1 Message Date
Ulf Hermann ab71cdafca QML: Warn about variables being used before their declaration
This collides with injected signal parameters. qmlcachegen cannot tell
those cases apart.

[ChangeLog][QML][Important Behavior Changes] QML warns about JavaScript
variables being used before their declaration now. This is almost always
a mistake. It is particularly dangerous in the presence of injected
signal parameters because qmlcachegen cannot identify a name collision
between an injected signal parameter and a variable being used before
its declaration. It therefore miscompiles such code. You can turn off
the deprecation warning using the "qt.qml.compiler" logging category.

Pick-to: 6.1
Task-number: QTBUG-89943
Change-Id: I8a9424ca8c6edd562402fe5c560ba7e8344b5585
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-11 17:37:53 +01:00
Alexey Edelev 5722f9e889 Enable tests of manually registered types
Enable tests of 'qt_manual_moc' and manually registered types for
cmake build

Fixes: QTBUG-84906
Change-Id: I98b8902d4a2b70d4e1e218d8bfdedce25be1abc1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-10 16:50:49 +01:00
Maximilian Goldstein e887f25dd6 Fix QJSValue string parameters used in signals
Pick-to: 6.1 6.0 5.15
Fixes: QTBUG-86482
Change-Id: If938fad22f51b08fe3cb20b94634efe46a1eed47
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-10 13:11:46 +01:00
Ulf Hermann 63bfaae1f5 Support and prefer QML_IMPORT_PATH over QML2_IMPORT_PATH
The 2 is meaningless.

Task-number: QTBUG-85064
Change-Id: I9f140155d274c691b5eab1285d9b7153f9f93a87
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-10 09:27:06 +01:00
Ulf Hermann b17ccb8af9 Use QLibraryInfo::QmlImportsPath rather than Qml2ImportsPath
The "2" is meaningless and there is a better name available now.

Task-number: QTBUG-85064
Change-Id: I65d26b06712ed7dcf2825f16dffaa6060dd86985
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-02-09 21:46:43 +01:00
Dmitry Shachnev dab0d62b65 Make tst_qmldiskcache::regenerateAfterChange() pass on big endian systems
We cannot use reinterpret_cast here, because testUnit->constants()
returns a pointer to quint64_le data, which needs to be converted to
native endianness first.

Here I used the QV4::Value converter that accepts quint64, so this
conversion now happens implicitly.

Change-Id: Iff6e3e4554af8890e61cb06e6fd79339c7a14653
Pick-to: 6.0 6.1
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-09 23:46:12 +03:00
Ulf Hermann 001596d472 Return errors if validation of inline components fails
Pick-to: 6.0 6.1
Fixes: QTBUG-90038
Change-Id: Ic01b5d097e0b9e6720bcec7ccb18c22abb5418f4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-08 19:12:31 +00:00
Fabio Falsini d0b1bef8b8 QQuickItemParticle give() method kill particle
Currently removing an item connected to a particle
only invalidate the particle that will be reused for
the next item set. This has the effect that the new
item inserted appears in the same position as the
old one just removed. This patch force killing the
particle to assign next item to a new particle
starting from initial position.

Pick-to: 5.15 6.0 6.1
Change-Id: Ic937a6d7aea65368cceb1405bb81ef1502d988a5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-05 23:37:26 +01:00
Maximilian Goldstein 33f3d70c74 qqmlproxymetaobject: Support invoking methods and slots
Previously this just failed silently and returned garbage data.

Change-Id: Ia8b72836aa0ccfd50fd18b0f813c2bf3a00801c5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-05 17:19:54 +01:00
Ulf Hermann 4938984f9a Use a QDoubleEndedList for the children of animation group jobs
This way it's fundamentally impossible to add the same animation job to
two different group jobs. The pointers are not exposed anymore and no
one can re-order the jobs.

Task-number: QTBUG-90401
Change-Id: Iebff4b64960c853915dd32714acd144fc5cdc00d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-05 15:20:02 +01:00
Ulf Hermann 680f28b08f QSequentialAnimationGroupJob: Protect against self-deletion
setCurrentAnimation() can indirectly delete the animation group job
itself by invoking the animation controller. Use the RETURN_IF_DELETED
mechanism to avoid the resulting dangling pointers.

Task-number: QTBUG-90401
Pick-to: 6.1 6.0 5.15 5.12
Change-Id: Ibd0ad21e8d3af4760604c3ff37dc46101d5f49ad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-05 14:19:56 +00:00
Samuli Piippo 1e8cb40d24 tst_qquickdesignersupport: blacklist tests that segfault on QEMU
Pick-to: 6.1
Task-number: QTBUG-90869
Change-Id: I70abb1baa2b919880bc711ee00d5fdbaef69301d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-02-05 13:44:58 +02:00
Samuli Piippo 34477bdbb0 tst_qquickitemlayer: skip tests when running on offscreen platform
More tests fail on offscreen platform when tested on QEMU on CI.

Pick-to: 6.1
Task-number: QTBUG-63185
Change-Id: I293e9b32078bf2567fbb9773cedf6777ad182a69
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-02-05 13:44:51 +02:00
Maximilian Goldstein 5164b36501 Import property benchmarks from private repo
Change-Id: If45bf9bfcfee127263a2c0e49cfa55e12f9a6d0f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-04 09:29:59 +01:00
Maximilian Goldstein 5fb34b67b8 qmllint: Fix segmentation fault
Pick-to: 6.0
Change-Id: Ie04ad4221b25628687c2575facf90488b83d21bf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-03 16:32:49 +01:00
Jan Arve Sæther 79014a1b39 QQuickListView: Add autotest so that animated delegate does not crash
This is separate from the fix, since the test is supposed to also be
merged into dev. (Where the fix was not needed)

Task-number: QTBUG-86567
Pick-to: 5.15
Change-Id: I2cf1a4b11eed4fe356588aeff322d3a432f0fe83
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-03 12:01:40 +00:00
Fabian Kosmale 0deb3961e6 QmlBind: support bindable properties
This patch ensures that the QML Binding element can also save and restore
C++ bindings. Should QQuickItem's x and y property be ported to the new
property system, we'd need new test cases to verify that "old-style"
bindings are still handled correctly. This task is however left for the
change porting the properties.

Task-number: QTBUG-90493
Change-Id: I506ffa1060ff32a7d722214e5ccd469bdaa61ff8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-03 09:28:40 +01:00
Fabian Kosmale b322a971f0 QQmlIRLoader: Actually load RequiredPropertyExtraData
If a QML component wants to mark properties of its "parent" component as
required, it can do so via
required propertyName
The information about those properties is stored in a
RequiredPropertyExtraData data structure. This structure is already
serialized to disk in the QQmlIRWriter. However, we neglected to restore
it so far in the loader.

Fixes: QTBUG-90538
Pick-to: 5.15 6.0
Change-Id: I789daff9bc881e4f35c942c77f5116b5284de81b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-03 08:49:50 +01:00
Ulf Hermann 1b93a1d865 qmltyperegistrar: Fix handling of default properties
Default properties are always local. There is no way to declare a
default property for a foreign type as the default property is queried
directly from the classinfo at runtime.

Change-Id: I30efb6fba190957ac2a4ad86da437f209cd1f3ad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-02 14:32:35 +01:00
Ulf Hermann 065c3f5732 Make the internals of QQuickAnimatorController private
No one should mess with those. All the pointers have complicated
ownership semantics. We can just befriend the test instead of making it
all public.

Task-number: QTBUG-90401
Change-Id: I6c4adbab7046b40db7f4628780ef928445ea3eb2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-02 14:17:14 +01:00
Ulf Hermann c892b26f06 qmltyperegistrar: Do not add extensions to local anonymous types
If we generate a local anonymous type, then that's the local part of a
QML_FOREIGN local/foreign couple. Any QML.Extended in there belong to
the foreign type.

Change-Id: Ic1706045eff03dd7b1b553240596ffc21818c8bd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-02 10:58:28 +01:00
Fabian Kosmale edca9f3d60 QuickTest: Do not recurse forever on inline components in enumerateTestCases
In TestCaseCollector::enumerateTestCases, we visit the super compilation
unit of QML tpyes to check if they might be instances of TestCase.
However, in the case of inline components, the super unit is the current
compilation unit, and we would recurse endlessly.

This does not address the issue that an inline component might actually
inherit TestCase. However, as this only affects the enumeration output
and does not actually affect test execution, this is not that much of an
issue. It should also be noted that the enumeration also fails in any
case where TestCases are loaded dynamically (with a loader), so the
method is not 100% accurate even in the absence of inline components.

Fixes: QTBUG-90740
Task-number: QTBUG-90762
Pick-to: 5.15 6.0
Change-Id: I7e133d62c4f62fc46e9bd3999ff755f7ded3c386
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-01 18:19:24 +01:00
Ulf Hermann f6fc35b45b QmlCompiler: Allow for multiple extensions per object
Previously, the assumption was that each object could only have a single
extension object. As proven by the new qqmllanguage test this is not the
case. Each registered object in the type hierarchy can have its own
extension. Therefore, adjust the algorithms that generate qmltypes and
iterate the extension objects when analyzing them.

This leads us to the realization that anonymous types can in fact
meaningfully carry extensions and implement interfaces. Adapt
qmltyperegistrar accordingly.

For the test to compile, however, we need to realize that the class
declaring interfaces needs to befriend all potential subclass's
QmlInterface structs. Fix that, too. The rabbit hole went deep.

Change-Id: Ia451897e927e03b95c3062e829edf1dfcd216613
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-01 16:51:51 +01:00
Edward Welbourne 24ec3b3e7f Prefer qHypot() over sqrt(a sum of squares)
It's apt to be more accurate and may even be optimised.
Comment on a benchmark where we could use Math.hypot(), but that would
break comparison with Qt 5 results.

Change-Id: I7c37dd3df82fdef18e7ebb0e1548198afd256faa
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-01 16:40:27 +01:00
Fabian Kosmale f5877880c5 tst_qqmlecmascript: Adjust to QObjectCompatProperty change in qtbase
Fixes: QTBUG-90786
Change-Id: Id05afbeb18b7c30246a29b95673a1319649f389f
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-02-01 12:59:59 +01:00
Fabian Kosmale eff73ee319 Expose getter and setter names of C++ classes in qmltypes files
This simply exports the name which are already available in the json
files generated by moc. We do not consider whether the methods are
non-private for now. MEMBER is not supported either, but might be added
if the need actually arises.

Fixes: QTBUG-90711
Change-Id: If3ee18c8ce60499676a7ee22df569cba0912e22f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-01-29 08:43:41 +01:00
Ulf Hermann b7bbdf7e7d V4: Store instruction pointer before CmpIn
The "in" operator may throw an exception.

Change-Id: I7d0b6e2212ac6ec237fbf14719349f8e23810028
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-27 10:54:18 +01:00
Volker Hilsheimer 8a485894de Make the nameFilters test resilient to file system changes
The test failed reliably when the directory in which the test started had
the same number of files as the directory that the test wants to read.
That's because the QTRY_COMPARE matches immediately and doesn't process
events, which leaves queued signal emissions pending. So, count tests
passed - for the wrong reason - and follow up tests failed.

To make the test robust, start with an invalid directory, which we know
is empty. Once switching into the test directroy, the test will have to
process events.

Remove the BLACKLIST file.

Fixes: QTBUG-90468
Change-Id: I9b3c4dc1a15b0b5ab6c632c12752b038164b9d9d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-26 21:41:26 +01:00
Ulf Hermann c87b4abdc0 QmlCompiler: Return after importing a script
If we don't return there, the newly imported script is promptly
overwritten by an invalid module.

Change-Id: I788a7275e2c190a20c176da35f5c76ac9f6ad02b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-26 13:53:41 +01:00
Ulf Hermann ed59dfeb70 qmllint: Complain if member access check fails for namespaced types
Before, we would prepend the namespace to the name, but then continue
right away, never checking the new name.

Change-Id: If90db7d33536fb4b549321c2d6b677040605b6f0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-26 13:19:38 +01:00
Ulf Hermann 74060990bc QQmlJSTypeReader: Guard against empty JS files
Change-Id: Ie52ce15b7fa960ce84a6d17a21a0e307a38c726e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-26 13:19:24 +01:00
Ulf Hermann 79ac5a2053 qmltyperegistrar: Make sure we have metatypes for all QML types
We need to be able to resolve any QML type from its C++ name using
QMetaType::fromName(). qmltyperegistrar can generate the missing
metatypes, either by creating synthetic ones (for namespaces), or by
making sure the existing ones are registered (for others).

Change-Id: If775af56d891f2c2a5bb94589b3cb05a199c7c35
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-25 16:53:32 +01:00
Fabian Kosmale 9eda73354c QQmlPropertyBinding: improve error reporting
This change ensures that bindings created in QML between new-style
properties contain information about which property caused the loop. To
do this, we store additional information about the property involved to
retrieve its name and position at a later point. We print the warning in
case we detect a binding loop in evaluate, and also set the error
reporting callback correctly, so that the condition can be reported when
the loop is detected in another part of the binding evaluation.

In addition, we do not only set the QPropertyBinding's error member when
JS evaluation results in an error, but also print the warning with
qmlWarning.

Fixes: QTBUG-87733
Change-Id: Idb25237d1f57355ca31189e6bf2a918430b3a810
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-01-25 11:21:42 +01:00
Ulf Hermann c1bcaca07f QJSEngine: Add a function to throw a pre-generated error object
It makes little sense that you can construct an error object but not
throw it. The test was definitely meant to actually throw the error
object, not return it.

[ChangeLog][QtQml] QJSEngine has gained an additional overload to the
throwError() method, with the effect that calling throwError() with a
character literal as argument is now ambiguous. You should explicitly
construct a QString instead.

Change-Id: I90c6c9edf10509daa142a86581d6a3f7ff45af2c
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-22 10:17:13 +01:00
Ulf Hermann 9b407b68d1 qmllint: Fix auto-importing of qmltypes from same directory
Fixes: QTBUG-90513
Pick-to: 6.0
Change-Id: Ic39e72d6df20be30c61123a7f8091d70dbc2d924
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-21 14:17:59 +01:00
Ulf Hermann 7290f9b82a Avoid memory leaks in QSequentialAnimationGroupJob test
Change-Id: Ib221f83ff80ed02f29b1dbe2767ccf63abf16738
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-21 13:37:00 +01:00
Laszlo Agocs 3fadfb2c3f Expose the list of preferred instance extensions to rendercontrol users
As all QRhi stuff is private, it needs to have a public counterpart in
Qt Quick in order to fully support the case of Vulkan-based
QQuickRenderControl usage.

Change-Id: Iaf9a7aa56022acd31af6ebf16de6b83a04966ff4
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-21 10:19:01 +01:00
Ulf Hermann 39944e8467 qmllint: Remove exceptions for most unknown builtins
All those types are properly defined in the qmltypes files now. We just
need to search the enumerations the same way as methods and properties
in order to find everything.

Also, deduplicate the code that resolves properties, methods, and enums
by using a common template for iterating the scopes.

Change-Id: I0bf1423974d0ec8f602ecd0342522b3e981a8586
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-21 08:45:16 +01:00
Andrei Golubev 90be89d771 Use new QObjectPrivate connection mechanism in dynamic connections
Old API assumes sender == receiver, which results in wrong handling of
connections when receiver is deleted: connection is not removed or
notified elsehow as it's not really tied to a valid receiver

Task-number: QTBUG-86368
Pick-to: 5.15 6.0
Change-Id: I0f3115f1b0f26cf353752ba2b8fd88e0f3bdd388
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-01-21 08:38:50 +01:00
Fabian Kosmale 3230caeeb5 Restore libfuzzer pro files
This is a partial revert of 78ab4b8d8b, as
the fuzzing infrastructure has not been migrated to CMake yet.

Change-Id: Iebd873ec3760c5394bc248ed853b57e168d0f05c
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
2021-01-20 15:23:08 +01:00
Ulf Hermann 3ae2a6a47c qmllint: Support extended types
Fixes: QTBUG-90448
Change-Id: I5fb6b3d9223ae95ca7e039c5b9139ed086052c29
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-20 13:33:52 +01:00
Maximilian Goldstein bf573ad295 QML_SINGLETON: Handle local create() functions with foreign types
Previously only the foreign type was searched for a create method.
Now the wrapping type can also contain it.

Change-Id: I05fb9e0c0a54c14530eb9adcae5a44df5c208be3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-01-20 12:07:34 +01:00
Fabian Kosmale e9997bc969 Blacklist tst_qquickfolderlistmodel::nameFilters on macOs
Task-number: QTBUG-90468
Change-Id: I9e6ec2a218ba09ef9819eddcd00d090a79cbc6ca
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-01-20 10:57:29 +01:00
Fabian Kosmale 09563cda63 tst_qquickloader: Make message matching less stringent
For some reason, we do not get the correct line number on macOs.

Task-number: QTBUG-90448
Change-Id: I8dc45011c68e2cbe0d30f4a54f48a74a5a6b0271
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-01-20 10:57:26 +01:00
Fabian Kosmale 81ba03768d qmllint: Skip failing tests
And do not choke completely on extended.

Task-number: QTBUG-90448
Change-Id: I4ac5742ec70f5ba1ed1403be444d9cc7229830c2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-01-20 10:57:23 +01:00
Fabian Kosmale e98b48f55c QQmlComponentPrivate::setInitialProperties: Do not silently swallow exceptions
Instead, log them with qmlWarning.

Change-Id: Icde7397085841a84aca8a81c716d552c4cd4485a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-01-18 14:58:30 +01:00
Ulf Hermann bdb2b66f3d Add support for extended types to qmltyperegistrar
We generate the extensions as separate types. This also covers the case
of value types being extended by "themselves". We can properly express
this now, so we don't need the hackery of generating the local members
of a type with QML_FOREIGN into the foreign type anymore.

This also fixes interfaces from local types being written for foreign
types.

Fixes: QTBUG-89501
Change-Id: Ic76acd7eef09a92c1e36bd7a649c7a2deb24597b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-18 13:42:48 +01:00
Fabian Kosmale 65b88e61a5 QML engine: Fix writing function to property through alias
We special case writing functions to properties, only allowing assigning
them to var properties and QJSValue properties.
This would however break when aliases are involved. This commit fixes
the issue by resolving the alias, and then checking and writing to the
resolved property.

Fixes: QTBUG-90373
Pick-to: 5.15 6.0
Change-Id: Ia09ebe92feeaf8359c99ff9aeadc676b9fcfaa07
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-01-18 13:20:12 +01:00
Allan Sandfeld Jensen 831efa14e9 Update hovered on disabled QQuickItems
Changes handling of hovered so that the property is still updated on
disabled items, so that other items can bind to it. This is in
particular useful for tooltips.

[ChangeLog][Behavior Changes] QQuickItem::hovered will now update even
when the item is disabled.

Fixes: QTBUG-30801
Pick-to: 6.0
Change-Id: Id17298f657d7631b0e5019138ba33a7d5f863475
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-01-18 11:55:02 +00:00
Fabian Kosmale 78ab4b8d8b Remove the qmake project files
Remove all qmake project files, except for examples which are used to
test that qmake continues to work.

Change-Id: Ic4abb72dc2dcd75df7a797c56056b6b3c5fe62ac
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-01-15 15:34:22 +01:00