Commit Graph

3671 Commits

Author SHA1 Message Date
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
Ulf Hermann 3747c02fe6 QmlCompiler: Handle ID lookups of incomplete types correctly
Incomplete types are generally stored in some wrapper type. We cannot
just assign to the accumulator. Also, we already know whether we have an
ID lookup there. No need to determine it again.

Pick-to: 6.2 6.3
Change-Id: I1f9fd9f147c44975df33fe862523987d8e711905
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-22 09:59:09 +01:00
Ulf Hermann 44ca135c5a QQmlProperty: Prohibit ID lookup on explicitly given object
If an object is given, we should only use that object.
Amends commit 21f15ede60.

Pick-to: 6.3
Task-number: QTBUG-100110
Change-Id: I51c0a44750c31984ba4937fb1cd2405dd93fcc19
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-21 16:22:28 +01:00
Ulf Hermann ea74a1a6c1 tst_qjsengine: Fix some memory leaks
Change-Id: Ie3244fb88e91df84837b3a8bac9e98fc75f2850c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-21 16:20:15 +01:00
Ulf Hermann 24e5b9090b QmlCompiler: Add C++ name also for types with no export candidates
Even if the type is only exported in a newer version of the module, we
still need to know about it in an earlier version, in order to resolve
base types.

Pick-to: 6.3
Change-Id: Ibc7940308e3c4aaebf9871a159e1d85f43cd7693
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-21 16:02:11 +01:00
Ulf Hermann 712b637b58 Rename "Basic Types" to "Value Types"
Internally they've been called "value types" all along. Now that we are
adding the ability to define your own value types the "basic" name is
not really fitting anymore. Value types can be quite complex.

Change-Id: I5fb4abec1dd2f0bbf7fb7f08b02db0882490e983
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-21 01:23:59 +01:00
Ulf Hermann e19d48d073 QmlCompiler: Respect revisions
The only place where revisions matter is at the boundary between
composite and non-composite types. The revision of the first composite
type inherited from determines which members of all composite ancestors
are available. Therefore, store the revision together with the base type
and pass it through the imports to have it available. Then use it to
check availability of methods and properties.

The test exposes two further problems, which are fixed, too:

1. If no method is found to call, we need to generate an error in the
   type propagator. We don't know what the call will result in, after
   all, and the code generator should reject it.
2. We need to check the right scopes for hasOwnMethod(). Otherwise we
   might not find methods that are available.

Pick-to: 6.2 6.3
Fixes: QTBUG-99128
Change-Id: I4c320b8dfb490b140d7b8c16e6b638b32f156faa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-21 01:23:58 +01:00
Joerg Bornemann 338e892a18 Remove unused .qrc files
Task-number: QTBUG-94446
Change-Id: Ib8e773f97fca0d296752fd006062b5841dfd5662
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-20 19:33:01 +01:00
Alexandru Croitor 0de113d379 CMake: Don't cross-compile qjtest
Previously it was only excluded on ANDROID, but cross-compiled for
other platforms.

The executable should only be built when the target Qt is meant
to be used as a development SDK, to be executed on some host machine.

Because at the moment we lack a proper abstraction for that, as a work
around, we exclude building it when cross-compiling.

The executable is not called automatically by any test, it is only run
manually by a developer.

In the future, the qt_internal_add_tool call should likely be replaced
by a customized qt_internal_add_app call, installing the executable
into $prefix/libexec rather than $prefix/bin.

Amends 5a55e52638

Pick-to: 6.2 6.3
Task-number: QTBUG-92591
Task-number: QTBUG-100040
Task-number: QTBUG-100047
Change-Id: If20e73fe378acd51fe41d181078d273a7842fc81
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-20 19:33:01 +01:00
Ulf Hermann 3027d8ed74 V4: Fix naming of array data classes
Provide convenience wrappers for access to const/mutable data, properly
discern between the "buffer" object and the actual data, especially
regarding shared/detached state.

Change-Id: I48f1f1eb8c204c29277746e5dee63892cbf3ac89
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-01-20 19:33:01 +01:00
Ulf Hermann 1fd5f00d91 Stabilize tst_qpauseanimationjob.cpp some more
Apply the same exceptions for macOS that are used for windows in select
places, and increase the timeout in changeDirectionWhileRunning().

Fixes: QTBUG-81938
Change-Id: Idae5ae8d125f106dcb74b75be2df0c417363e7cc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-20 11:51:18 +01:00
Andrei Golubev de30f10aeb Document qmltc tool
Add initial qmltc tool documentation with introduction,
compilation process picture, description and limitations

To simplify the description, we can consider some simple
application. The same app can additionally become a test
scenario for qmltc and a showcase of its capabilities

Task-number: QTBUG-84368
Pick-to: 6.3
Change-Id: If6d586a8c68f48d17133b25170d0fff627e2066c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-19 14:47:46 +01:00
Ulf Hermann 6a54c6013d QmlCompiler: Handle context push/pop in dead code
Otherwise we end up with unmatched curly braces in the generated code.

Pick-to: 6.2 6.3
Change-Id: I4c24d4062a8ed54cd6a9ecb43dfd2b5d0a26c9e1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-01-18 12:51:38 +01:00
Ulf Hermann 3833e92911 Simplify QQmlMetaTypeInterface and QQmlListMetaTypeInterface
The previous code gave the impression that we actually had a C++ type
there. We haven't. The whole metatype is built only on QObject. Admit
that and simplify accordingly. Also provide a way to retrieve the
correct metaobject. A metatype for a QObject* that doesn't provide a
metaObjectFn is unexpected and causes crashes elsewhere.

Change-Id: Iccb0b72d325ea77fb0cf83f7acbe2ef9fe0e06b4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-18 12:51:38 +01:00
Ulf Hermann 5f76fabd06 Move propertyCache- and metaObject-related functions into QQmlMetaType
That's where the data resides. This allows us to lock the mutex only
once for all those methods, and it makes a large number of engine
pointers unnecessary.

Finally, we can now find the element type of a QQmlListProperty without
supplying an engine.

Change-Id: If1ae8eafe8762a112d1ca06f9c92ab8a727d1bda
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-18 12:51:38 +01:00
Ulf Hermann b245faae89 QmlCompiler: Construct multi-part URIs with '.' rather than '/'
This is how URIs are defined and how we store them in our caches.
Without this, we cannot find modules with multi-part URIs imported using
-i.

Pick-to: 6.3
Change-Id: I86b02b2c2102a2d4edd8c20388c6cd9b1e92b0ff
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-18 12:51:38 +01:00
Ulf Hermann 134f305b7f qmltc: Do not generate bindables and setters for QQmlListProperty
Assigning to a QQmlListProperty does not do what you think it does.

Pick-to: 6.3
Change-Id: Ie6ac3208d552d8f40d9f2f4d7fb33c1cd64e4b79
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-01-18 09:37:27 +01:00
Maximilian Goldstein 0790bc85a1 qmlcompiler: Add proper null type
Previously we treated null as a generic primitive value (in functions)
or as a var type (in literal bindings), this change ends this practice
by introducing an uniform null type used everywhere and defined in
builtins.

Now we can also properly warn about setting properties to null if they
aren't variants.

Fixes: QTBUG-98409
Change-Id: If32420a59948696491f24521bbc0f251095a9699
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-17 19:53:06 +01:00
Maximilian Goldstein 2ffed97aac qmllint: Offer suggestions for typos
Automatically suggests fixes if a user has a typo in the naming of a
component, property or binding.

Also now warns about calling undefined functions.

[ChangeLog][qmllint][New Feature] qmllint will now automatically suggest
fixes if it thinks a component, property or binding was not found due to
a typo.

Fixes: QTBUG-97693
Change-Id: Ia66c1ba84e187a2eb31bbdf33ca30d7e5141bea9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-17 12:36:04 +01:00
Maximilian Goldstein f19582f630 qmllint: Enable compiler warnings for pragma Strict
If a file sets pragma Strict, it expects to be fully compiler
compliant, so let's enable the warnings for that by default.

Fixes: QTBUG-97081
Change-Id: I0b388f64d99846ee0c03e24397b3a997d4b0173b
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-17 12:35:54 +01:00
Ulf Hermann bd0f4459ce Re-allow retrieval of list properties in QQmlJSCodeGenerator
It's not particularly slow. It probably was when we were using
QQmlListReference or JavaScript arrays.

Pick-to: 6.3
Change-Id: I1a4575a5b84cdfb732a6c3615d00bbe2abaffc94
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2022-01-15 14:22:42 +01:00
Maximilian Goldstein fddd82345a qqmljstypepropagator: Add compiler error for unknown function calls
Previously we would not generate an error when an unknown function was
called.

Pick-to: 6.2 6.3
Change-Id: I31845a642afe0fd6038228c4aabf2ef5c6f1140e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-01-13 15:35:31 +01:00
Maximilian Goldstein dd0e69a20b tst_qmllint: Fix settings tests
Some of the settings tests were broken in a way where they could never
fail, even if the feature was broken. This is fixed now.

Also expanded the tests to also cover the additional qml import path option.

Change-Id: Ibd5b8fde36362ccf0cc3b9d7d639c2485fd6ae77
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-13 15:35:24 +01:00
Andrei Golubev feaed5f7aa Enhance tst_qmltc::componentTypes() by verifying that ids are correct
We can in fact check that the ids match to correct objects

Pick-to: 6.3
Change-Id: I46ed1a3d0a9ef429670fdc0438a5d717971c459c
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-12-28 09:20:24 +01:00
Andrei Golubev 39aee682bf qmltc: Support Component roots
It is a very special case that doesn't undergo a normal compilation but
instead just uses QQmlObjectCreator::createComponent() logic.
As QQmlObjectCreator::createComponent() returns a new QQmlComponent,
we can't use it within the qmltc-generated type's ctor. Instead, just
fake the same flow by incorporating the code into the qmltc type
setting

As a drive-by, fix the code to work correctly with Component roots.
This should now pretty much cover all the mystical logic of
QQmlComponentAndAliasResolver and, with tests, we can safely simplify
the qmltc code generator bits later without introducing bugs

Enhance tst_qqmlcomponent::componentTypes test to highlight that
property Component p: ComponentDerivedType {} is not marked with
QV4::CompiledData::Object::IsComponent flag at all and thus considered
to be an ordinary object binding, unlike
property Component p: NotComponentDerivedType {}

Pick-to: 6.3
Change-Id: I4ec41952d15f9659d316e44dab4050aa4908327c
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-12-27 08:27:04 +01:00
Andrei Golubev e659b5b23a Skip tst_qmltc::listView() under QEMU
It seems flaky and I fail to see any reasonable explanation for this

Task-number: QTBUG-99355
Change-Id: I21880b6d041cfc21cf847fc3e4f09563be2c5569
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
(cherry picked from commit 7f731838b0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2021-12-26 11:17:28 +00:00
Andrei Golubev 85eb0481ea Separate JS files from QML files in qmltc-calling cmake command
Produces annoying CMake warning, so just not include javascript files
for qmltc to process

Pick-to: 6.3
Change-Id: I833dc21d927da10a33b2f382a13bc38a47b4f686
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-12-23 18:42:59 +01:00
Andrei Golubev 7b25a46fc7 qqmlcomponent: Test interesting Component-based types
1) we do not allow "empty" Component objects
2) explicit components leak ids when used in implicit component setting
   (unlike non-components)

As of now, just "document" this behavior by adding an extra test

Change-Id: I42346217c2d6aed661c2e58d4c01a580c89a1fae
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-12-23 15:56:16 +01:00
Andrei Golubev 71084db1df qmltc: Support different property change handlers
qmltc must be able to compile property change handlers:
- for bindable properties (with no notify)
- for notifiable properties (with no bindable)
- for both bindable and notifiable properties (preferring
  notify signal)

Test the aforementioned cases and some signal handling cases
along the way

Task-number: QTBUG-84368
Pick-to: 6.3
Change-Id: I2cd2d0ad6407889942c806e03831dec4c7ce265a
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-12-23 15:56:16 +01:00
Andrei Golubev 72efa7f981 QQmlJSImportVisitor: Fix property change handler detection logic
We can have weird cases like `onXChanged: {}` with x's NOTIFY named
xNotReallyChanged and those should still function correctly; bindable
properties without notify can also use property change handlers

Picking to 6.3 as this is pretty much a bug + qmltc needs this as well
to support the weird cases (as otherwise it'll just fail in the visitor)

Pick-to: 6.3
Change-Id: Ib9a1ce8b7d76133a89bcf0dab16f25659ce69c2b
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-12-23 13:16:38 +01:00
Andrei Golubev 0d40cde68e qmltc: Fix explicit import of local QML types
qmltc passes re-import local QML types in order to get their URLs and
modifiable versions of types. The existing logic seems to work only
when we've already imported the types before. But re-import may, in fact,
easily load *same* types from a *different* place. This is totally wrong
and exceptionally evil (even within the passes). Re-write this logic by
looking up the already-imported types from QQmlJSImportVisitor instead

This, in particular, fixes a case:

import MyOwnModule 1.0
MyOwnType { } // oops, does not include "myowntype.h"

Pick-to: 6.3
Change-Id: I35be7e41094c3bb9e210727a7a59bee33b548698
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-12-22 15:43:23 +01:00
Andrei Golubev 790d257ef0 qmltc: Do not crash on import namespaces
Pick-to: 6.3
Change-Id: I9767857076ea6ae565c7efd75d64cb47a82b7be7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-18 21:58:05 +01:00
Andrei Golubev 362b4bf3d6 qmltc: Be aware of Component-wrapped types
While implicit components (the ones bound to Component-based property)
are covered, cases like `Component { Text{} }` are not, so fix that

Revisit the logic in the QmlIR / QQmlJSScope passes and code generator
as part of this

This might be a fairly used pattern in QML so no reason not to address
this right away, especially given that we have most of the
infrastructure in place already

While at it, bring over extra tests that some other (non-merged) commit
introduced. These give good coverage for missing cases and also exercise
the feature supported here

Task-number: QTBUG-84368
Pick-to: 6.3
Change-Id: I8f5c74fc79380566475b1139d4cc5560fac123e3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-18 14:40:19 +01:00
Alexey Edelev e0a6ee877d Add prefer record to the output of qmlimportscanner
Pick-to: 6.3
Task-number: QTBUG-95984
Change-Id: I2e126db655ef986b23d66a465e8b28b9fb17bbb1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-17 20:48:10 +01:00
Andrei Golubev 8fac197ba2 qmltc: Explicitly reject inline components
Because they seem to be hard and there's little reason to invest
in their support immediately

Task-number: QTBUG-84368
Pick-to: 6.3
Change-Id: If056aa401d8f54d067eb583669074cb3f6bfd304
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-17 16:46:52 +01:00
Maximilian Goldstein 89bcf7e7c8 tst_qmllint: Port remaining tests to the library
Ports all the remaining tests that can be ported to use the library.

Change-Id: I030a97fc3957c2f4f5e3bdd98ce9d5b0b87e5638
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-17 16:46:52 +01:00
Ulf Hermann 0ea14fa126 QmlCompiler: Don't try to get attached objects for non-QObject*
We might end up in this situation if we don't know enough about the
base of the attached lookup. This would generate invalid C++ code.

Pick-to: 6.2 6.3
Change-Id: I210077388d0d1d0d4e9454bd3ba3792af9b42049
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-17 12:43:14 +01:00
Ulf Hermann f6294b7938 Do not return a null scope from storedType()
We can store everything in a QJSValue. Returning an invalid scope
triggers inadequate code paths later on.

Pick-to: 6.2 6.3
Change-Id: I700d7a3219e5784d3ec125806f70018417ceac14
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-17 12:43:14 +01:00
Maximilian Goldstein 687609f2f3 Move QObject and QQmlComponent into builtins
Previously we had two versions of QObject and QQmlComponent: a
hand-written version in bultins and one that is generated from QtQml.

We now move the QtQml version into builtins in order to allow for
representing the JavaScript extensions that are present in these types.

We also add some logic so that unused types will still react properly
despite the fact that those components are no longer in QtQml.

This is done by introducing the concept of static modules. These are
modules that have side effects beyond simply provinding components. This
applies both to when some components are in builtins instead of QtQml or
when the global object is modified in some way (i.e. by adding an image
provider). This is a tooling-only concept and does not affect how these
modules are handled at runtime.

Fixes: QTBUG-99025
Change-Id: Ifacaa836e4d2eef0521494f5a41363e053c90007
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-17 12:43:14 +01:00
Assam Boudjelthia 6e6e22b07d Skip test cases execute the app's main shared lib on Android
Because on Android the project main target is compiled into a shared
library.

Pick-to: 6.2 6.3
Task-number: QTBUG-99214
Task-number: QTBUG-97056
Change-Id: Ia0b5d84f6a07964ce7e1802c42a9b35675248e51
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-17 13:43:14 +02:00
Assam Boudjelthia 1b242589a1 Skip host tools tests like qmlimportscanner on Android
Pick-to: 6.2 6.3
Task-number: QTBUG-97056
Change-Id: Iaef3b9cfcd5c58968d48e0b7381749c2c5c7fcba
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-17 13:43:13 +02:00
Assam Boudjelthia 91930dd3d7 Add dummy_imports for qmlimportscanner to find the correct dependencies
Otherwise, some dependencies won't be fulfilled and the following will
fail:
 component.setData("import QtQml\nQtObject{}", QUrl())

Pick-to: 6.2 6.3
Task-number: QTBUG-97056
Change-Id: If53c77b992a01051d7e83378723000615be9dfe8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-17 13:43:13 +02:00
Assam Boudjelthia 36874e799a Use the correct scheme in setUrlHandler() for openUrlExternally() tests
testFileUrl() can return a QUrl with either file or qrc scheme, so the
handler need to register the correct scheme as well.

Task-number: QTBUG-97056
Pick-to: 6.2 6.3
Change-Id: I87028f75bbaf267b5eb58d28497cd2bea593c02a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-17 13:43:13 +02:00
Alexey Edelev 1d135de5cf Add listing of the components and scripts that belongs to the qml module
Add qml components and scripts to the qmlimportscanner output to give
information about files that actually belong to the qml module.

Pick-to: 6.3
Task-number: QTBUG-97834
Change-Id: I41394ba6fe9d9fe3af74786b4a802903849ae27d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-17 12:43:13 +01:00
Andrei Golubev e7ce5abf24 Use qmltc compiler prototype as a fallback implementation
Task-number: QTBUG-91927
Task-number: QTBUG-96041
Task-number: QTBUG-84368
Pick-to: 6.3
Change-Id: I47320b5f3ed8efff6fb234778df5fae5be5b64f2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-17 08:57:27 +01:00
Fabian Kosmale 096a1c4f6e Warn about duplicated ids
Besides emitting a warning in case of duplicated ids, this commit also
refactors the id handling by moving it out of the generic visit
function, into a dedicated method. Moreover, internal documentation is
added to various functions in QQmlJSScopesById, and a new function to
quickly check for duplicated ids in a file is added. While those
conflicts do not necessiate an id duplication (they could be in
different components), this allows for a quick pre-check, and might be
later used to print a non-fatal warning about the potentially confusing
id reuse.

Fixes: QTBUG-99179
Change-Id: Ia99ebd17491d91d6f7747d65b3a8d15fa1f84e07
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-16 21:03:31 +01:00
Fabian Kosmale c7e8989274 Blacklist even more flaky timer tests
Pick-to: 6.3
Task-number: QTBUG-99143
Change-Id: I81514075ef6c6dceb8b09b82766d5c8ba9813173
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-15 18:07:35 +01:00
Fabian Kosmale aab386753b Blacklist flaky tst_QSequentialAnimationGroupJob test on macos
Task-number: QTBUG-99175
Task-number: QTBUG-99174
Pick-to: 6.3
Change-Id: I544a5df72b94bf06c906e70fb38a1374e9cf3575
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-13 22:21:44 +01:00
Maximilian Goldstein e83fd85cce qqmljstypepropagator: Use variant type for arguments of unknown type
Previously those function arguments would result in an invalid type
being used which lead to crashes when invoking methods using those
arguments.

Pick-to: 6.3
Fixes: QTBUG-99027
Change-Id: I27e643f2512e1542d766b5fe98adfee043245c6f
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-13 18:20:33 +01:00
Fabian Kosmale 3a4828460e Blacklist even more flaky timer tests on macOs
Taks-number: QTBUG-99143
Pick-to: 6.3
Change-Id: I8f38dae6b6407632128cc0e4d739d911f81361e0
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2021-12-13 12:51:44 +01:00
Ulf Hermann ce7a001b6b QmlCompiler: Clean up directory imports
We can cache directory imports just like anything else, and we should
processImports() them.

Change-Id: I5d66b789e8f6766380415c589de4357932d9fb9b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-13 12:51:19 +01:00
Ulf Hermann 576fafd1e6 Pass qmldir to qmlcachegen, qmllint and qmltc, not the qmltypes file
The tools will still grudgingly accept qmltypes files being passed via
the -i option. We generally expect qmldir files, though. Ignoring the
qmldir file and importing the qmltypes directly, ignores qmldir imports,
dependencies and other component entries. This leads to unresolvable
types.

[ChangeLog][QML Tooling] qmllint expects qmldir files, not qmltypes
files to be passed via the -i option now. This enables it to see the
imports and dependencies of the module being imported. For backwards
compatibility it still accepts qmltypes files, with a warning.

Pick-to: 6.3
Fixes: QTBUG-99043
Change-Id: I5ed32d7e78df1e604aaf1bfa2ebda09d5d57b628
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-13 11:51:13 +00:00
Ulf Hermann 22f4306283 QmlCompiler: Reject ambiguous and inaccessible types
If a type is not accessible in the imported version of a module, exclude
it. If we find multiple types for the same name and version, drop them
all and warn.

Pick-to: 6.2 6.3
Fixes: QTBUG-99113
Change-Id: I91d99d603ada6cf87f84afdbb01a543880d9aa76
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-13 11:51:06 +00:00
Shawn Rutledge ea48b0e129 Blacklist failing tests on macOS arm
Task-number: QTBUG-81938
Task-number: QTBUG-99149
Change-Id: Ia982300a3069014f841a04f19b5358aef0cf8673
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-12-12 14:39:37 +01:00
Ulf Hermann dd0b82abdc QQmlJSImportsVisitor: Break inheritance cycles
If we keep them around, later passes on the same data may run into
infinite loops. We cannot fully prevent any further processing of the
data because the import can happen from deep within a hierarchy of
components and modules.

Also, separate the deprecation check from the inheritance check.

Pick-to: 6.2
Change-Id: I62ce7cd15be83f60cd72b63ab858632fbc7dea66
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-12 12:05:28 +01:00
Fabian Kosmale 280a1c013c Blacklist flaky qqmltimer test on macOs
Taks-number: QTBUG-99143
Change-Id: I7d7badb3beed1631ae3d579b7090297573cb5120
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-12 12:05:28 +01:00
Volker Hilsheimer d62c216cbd Don't crash when accessing QVariant data pointer
The write method is called with a QVariant, and even though the property
might be of a QObject type, the variant might not contain a QObject. So
accessing the variant data directly via QVariant::constData and
static_cast'ing the void* to QObject* is not safe.

Add an explicit check before accessing. An alternative would be to at
least Q_ASSERT that the result of the cast and a QVariant::value call is
the same, which would then not introduce any performance penalty in
release builds. However, users use release-builds of qml and Qt tooling
to write QML, and we writing wrong QML code should not crash then
either.

Include a test case that segfaults without the fix.

Pick-to: 6.2
Fixes: QTBUG-98367
Change-Id: Ib3ae82d03c9b2df6251ee88d5bd969dd4f796a41
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-11 06:13:37 +01:00
Maximilian Goldstein 764972346a tst_qmllint: Port more tests to use the library
Change-Id: I01e4e3666b3ace74e9ffa46b113ed29af6d47ba5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-10 17:11:09 +01:00
Maximilian Goldstein 52c09a27ef qmllint: Use fix suggestions in a more structured way
Fix suggestions are now attached to the warnings they are caused by
and are also accessible via JSON.

This allows us to use the qmllint library for more of tst_qmllint,
greatly improving performance.

Change-Id: Idd0398028bff1272a75dc1193d2c15a25d335dbf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-10 17:11:05 +01:00
Ulf Hermann 2aa118c118 QQmlJSAotContext: flushPendingBinding() before capturing a property
This avoids duplicate evaluation and binding loops.

Pick-to: 6.2
Change-Id: I5eba42d9dca0782dd964bd64c088c2e158faa9b3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-10 10:06:28 +01:00
Shawn Rutledge 8326ff2ac1 Instantiator: don't interfere with delegates that assign parents
[ChangeLog][QtQml][Instantiator] Instantiator now avoids re-assigning a
delegate object's parent to itself if it was already set; thus, you can
now declare a parent assignment.

Task-number: QTBUG-64546
Task-number: QTBUG-84730
Change-Id: I7d95fa76e71c363b4cb5b7a512c2e984488c8af4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-12-10 06:52:35 +01:00
Ulf Hermann af356e3bc8 qmlcachegen: Don't generate bad code if we cannot resolve a return type
If we cannot resolve a return type, we need to refrain from calling the
method.

Pick-to: 6.2
Task-number: QTBUG-99042
Change-Id: Ie5ba0367c83c178f7e5c112072ca97d3c1c1fb1f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-10 02:42:47 +01:00
Ulf Hermann 25333a6af2 QmlCompiler: Split type name by last "::" rather than first
The outer type name can include namespaces, the inner one cannot.

Task-number: QTBUG-99042
Change-Id: Idaa3abbfa7b4ff0c908edd7fdee5c4e2ba0337dc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-10 02:42:47 +01:00
Ulf Hermann 34a070c351 qmllint: Avoid test failure if Qt5Compat is installed
They do have a qmltypes file these days.

Change-Id: I76b36711fea7ddf4026a87298ba76cc2eb7a049c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-09 23:16:36 +01:00
Maximilian Goldstein a350af2eb6 qqmljstypepropagator: Do not assert on baseType being non-zero
Fixes: QTBUG-99027
Change-Id: Ia1fd9a14f5d45d9a63b630b471bdad1b9c4c273d
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jaeyoon Jung <jaeyoon.jung@lge.com>
2021-12-09 09:25:38 +01:00
Fabian Kosmale d7119d327c qmllint: Initial translation binding support
We will need to distinguish between script and translation bindings in
the future (to correctly assign script binding indices). Moreover, the
NOOP translation functions actually produce string literal bindings, not
translation bindings.

To unify the classification of translation bindings, the code from the
IRBuilder has been converted into a template taking a few callbacks.

This change does not add validation for translation bindings yet, but a
failing autotest for a case where it would be necesseray is already
provided.

Change-Id: Icccba98edbdcd15068188807e8622c1bd513725c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-08 14:38:21 +01:00
Maximilian Goldstein fa2569262f tst_qmllint: Use library for verifying qmltypes
It's a lot faster and does not need any additional adjustments.

Change-Id: I84e90c032001a1940b6c956ba21746c6f1617c7b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-12-08 10:23:59 +01:00
Fabian Kosmale 7917b7ad64 qmllint: Warn about assigning numeric types to strings
While it is generally possible to assign a numeric to a value of string
type, this is not the case for literal bindings: There, the engine's
QQmlTypeValidator notices the mismatch, and rejects the program.
Bring qmllint in line with that behavior.
Additionally, teach parseLiteralBinding to treat constant
UnaryMinusExpressions as NumberLiteral bindings.

Change-Id: Iad221e90eb1de81cabdddf5d601cc30f53ef20d3
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-12-07 21:51:52 +01:00
Fabian Kosmale 30251c0781 qmllint: handle string template literals
A template string is always a string, so we can check it as such. If
there are no substitutions, the resulting binding is a string literal
binding, otherwise it is a script binding.

Change-Id: Iecbaed04bfee517668788552af659c9e81d92f71
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-12-07 21:51:52 +01:00
Ulf Hermann 0b175cb865 qmllint: Fix diagnostics output for test run
We do want to see the output if the cleanQmlCode test fails.

Change-Id: I6b7e9d3412af9fffac68d2e394418de2faf09626
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-12-07 16:01:02 +01:00
Ulf Hermann ffe31b09bb qmllint: Match non-composite types by name when converting
We can have multiple registrations for the same type. However, internal
names have to be unique. Use that property in canConvertFromTo().

Fixes: QTBUG-98924
Change-Id: I9479a1d48ba5b3eee01881cb7fc8998b0f23a52b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-07 02:40:56 +01:00
Andrei Golubev 9dc7c21321 Fix top-level build of qmlcppcodegen tests
The following is observed with a clean top-level build:
CMake Error: AUTOMOC for target codegen_test_moduleplugin: The "moc" executable "<path>/qt5/qtbase/libexec/moc" does not exist.
CMake Generate step failed.  Build files cannot be regenerated correctly.
CMake Error at /home/ag/work/qt5/qtbase/cmake/QtProcessConfigureArgs.cmake:928 (message):
  CMake exited with code 1.

Amends 58ff7aa4fe

Change-Id: I5b617de11520e13decb987bea377430b7a23fc75
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-06 22:43:08 +01:00
Ulf Hermann 1003626e6a QmlCompiler: Fix return type calculation
We can return void from a function, explicitly or implicitly, and we
need to be able to wrap that into a QVariant. In order to explicitly
return void, we need the void type to be exposed and understood.

Pick-to: 6.2
Change-Id: I513cabb25469b89a85b5d212a6825a037400729d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-06 19:35:50 +01:00
Fabian Kosmale f8f50d12dc qmlRegisterTypesAndRevisions: Simplify template
Using a fold expression ought to be faster to instantiate than the
recursive template calls.

Change-Id: Iffed70a2da74399bf96a9f78bfe1bb9a65d0be30
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-06 14:29:49 +01:00
Richard Moe Gustavsen fb954b07f2 qmlmodels: add qqmltreemodeltotablemodel
Add a proxy model to qmlmodels that takes a tree model
and converts it to a flat table model. This model is
used by TreeView to show a tree model inside a
TableView. It is mostly a raw copy of the model used
by TreeView in Controls 1 (and later by TreeView in
Marketplace), but with some modifications to target
TableView (with multiple columns) instead of
ListView.

Change-Id: I079937f35ae36659a6ad43375ac3d1d5840155d6
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-12-04 23:41:40 +01:00
Ulf Hermann b7b5127747 Test that we can retrieve attached types from "recursive" names
This is what the various SelectionRectangle.qml types in qqc2 do. Amends
commit e6c44662cdc8acfbdbf1c7ed071e1253ff0c1321.

Change-Id: Icb98f262d669ed165a3b3ab1be79b150b6cedc44
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-04 17:11:27 +01:00
Ulf Hermann c9112c210f Unify C++ and QML-defined JavaScript functions
They are the same for all intents and purposes. We don't need to expose
QQmlV4Function in the builtins.

Change-Id: I4c3f9a9c802abb3ce1133979007919eb69b46ae0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-04 17:11:27 +01:00
Ulf Hermann 58ff7aa4fe Compile QML files ahead of time with qmlcachegen
qmlcachegen compiles bindings and functions to C++ as far as
QQmlJSAotCompiler can. It does respect "pragma Strict" and rejects the
file if it's violated. Furthermore, it sets up the logger to follow the
qt.qml.compiler.aot logging category. By default it's completely silent.

Compiling the examples with qmlcachegen exposes a bug in the type
resolver where it returns an invalid generic type. It should never do
that. Fix it by returning JSValue.

[ChangeLog][QtQml][Important Behavior Changes] QML bindings and
functions are now compiled to C++ by qmlcachegen, if possible. Use the
qt.qml.compiler.aot logging category to receive diagnostics about the
compilation.

Task-number: QTBUG-98305
Change-Id: I6953812c3fd20b68339617a5714fcbe16a384360
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-03 12:09:26 +01:00
Ulf Hermann 7d911956b9 QmlCompiler: Disallow access to IDs in other components
There is no guarantee that this works.

Fixes: QTBUG-98830
Pick-to: 6.2
Change-Id: Id205170a41caa4bed264864a1ff35a57303641e9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-03 08:20:52 +01:00
Mårten Nordheim 06e68e0cc0 qqmlxmlhttprequest: Fix h2c fallout and ignore in future
The headers were hardcoded but seeing as they are ultimately ignored
on the server-side (which is following the spec) we can also ignore them
if they come back in some form in the future.

Pick-to: 6.2
Fixes: QTBUG-98811
Change-Id: Ida490cbd8193eb3e3bf8d56fd387af93c408d921
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-02 12:52:57 +01:00
Maximilian Goldstein 10d849e9d3 qmllint: Warn about nested ids in deferred properties
Previously we only warned about top-level ids in deferred properties,
now we warn about them at any depth, as we should.

Change-Id: I9b21bd4f71995eb51542f1e1e8a1c17c509b59da
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-30 19:42:54 +01:00
Ulf Hermann e0cd201e91 Qml: Don't crash when as-casting to type with errors
Such types don't have a compilation unit, but we still know their names.

Pick-to: 6.2
Fixes: QTBUG-98792
Change-Id: I2db8dea3a5a02ec1492f7f7a054fd3ad4c6ad69a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-11-30 19:42:54 +01:00
Ulf Hermann 7b68b800ec qmllint: Don't crash when retrieving properties from JS globals
The type resolver should never return an invalid type from storedType().
Everything can be stored somehow.

Pick-to: 6.2
Change-Id: I7048518ac1d16342a52164a0a91c41c3d63f349b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-30 19:42:54 +01:00
Ulf Hermann e551331f38 Add a default implementation for QQmlJSAotCompiler
The default AOT compiler compiles QML code in indirect, dynamic mode. It
uses the logger's Log_Compiler category to determine the verbosity of
its output. In addition you can use the qt.qml.compiler.aot category for
even more verbosity. In preparation for using QQmlJSAotCompiler with
qmlcachegen, the default level of that category is increased to
QtFatalMsg. The highest level we actually output is QtDebugMsg, so it
doesn't make a difference yet.

If the logger's Log_Compiler category is set to produce errors, it will
qFatal() on "pragma Strict" violations.

Change-Id: Ieb74bfa7cd51cfa8616792ab467c32f6ba0e0702
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-29 23:12:45 +01:00
Kai Köhne 88fb3b4043 Fix license of tests from LGPL3 to GPL-EXCEPT
Autotests in Qt are usually GPL3, or BSD. No point in using the LGPL
here.

This also gets rid of last references to LICENSE.LGPLv3 in this
repository, so we can delete both LICENSE.LGPLv3 and LICENSE.GPLv3,
which it references.

Change-Id: Idbdefe0c68cc8047ede72b439a4d7ff40dfd71b6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-29 09:22:01 +01:00
Maximilian Goldstein d8e73b588a qmllint: Properly handle JavaScript functions with variable arguments
Previously calling a JavaScript function with variable arguments could
cause the linting process to error out because of a lack of matching
function arguments.

This is now handled by defaulting to a JavaScript method if no matching
function signature can be found.

Fixes: QTBUG-98299
Change-Id: I748a60839106243a12bffd8d715b48cbc53d7f57
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-26 21:23:08 +01:00
Fabian Kosmale 04f635b808 tst_qqmlxmlhttprequest: Skip locale dependent tests
...in case the locales is not en-us. Ideally we would make the test not
dependent on the system locale, but the best way to achieve is not
clear, and skipping tests that have no chance of succeeding is the next
best thing we can do.

Pick-to: 6.2
Fixes: QTBUG-59223
Change-Id: I1d7dfca267b01b701e369043d028d61f2f687fcd
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-11-26 15:57:02 +01:00
Fabian Kosmale e743b6e5e9 qqmltypecompiler: Be conservative in enum optimization
QQmlEnumTypeResolver constains logic to find enumerations in bindings
and turn those bindings into simple integer bindings. However, that
logic got confused when we had a complex expression (as in, not only an
identifier but any compound expression).
Instead of trying to create a mini-expression parser, we opt to be more
conservative in the analysis and reject anything that does not look like
one or more identifiers separated by dots.
The use case of optimizing simple arithmetic operations involving enums
in bindings is left to qmlsc.

Pick-to: 6.2
Fixes: QTBUG-98311
Change-Id: I6f8c3fa2a2712dabdea035e2447d52c415ebfc3f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-26 15:57:01 +01:00
Fabian Kosmale 96c1337aef Support QML type registration split: build system + tools integration
This change addresses the following issue:
- Module A wants to have an optional QML API without depending on
  declarative (e.g., because it has a C++ only API usable for Widgets
  based applications that normally would not link against declarative).
- Thus we add a module B with all the QML support (type registration,
  maybe additional types/functions/image providers).
- Currently, this would require to wrap every type from module A into
  QML_FOREIGN manually, adding large amounts of boilerplate.

To solve this, we extend qmltyperegistrar and the CMake API:
- qmltyperegistrar gains a new --extract option to generate a file with
  all QML_FOREIGN declarations. More precisely, it generates a header
  and source file; the source file includes the header and the moc
  generated file.
- We expose this in cmake via a new qt6_generate_foreign_qml_types
  function. That function takes two targets, the source library's target
  and the QML module's target. It then runs qmltyperegistrar on the
  source library, and adds the generated files to the QML module's
  target, and adds the proper dependencies between the targets.

The remaining step to achieve the goal of split registration is to
provide the QML registration macros in a separate header.

Task-number: QTBUG-92258
Change-Id: I51c4ef660ca7476b556b1991a6c76bbcad2c69af
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-26 15:56:59 +01:00
Ulf Hermann 17bfd9c694 QmlCompiler: Tighten the constness of various method parameters
The compile passes shouldn't need to change the document, AST, or IR. At
least not accidentally. We might add interfaces to explicitly modify
things later. As a side effect, you can now use one instance of
QQmlJSTypeResolver for multiple documents by re-init()'ing it.

Change-Id: Ic3544b3ddedd30d7f8d00b1df9cee3e6292ca7de
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-26 11:57:57 +01:00
Ulf Hermann cb3ec010ff QmlCompiler: Move type generalization into separate compile pass
We want to be able to skip it.

Task-number: QTBUG-98305
Change-Id: Ibb0293d348f2828a28be4c458cf955b4cc706caa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-26 11:57:52 +01:00
Ulf Hermann ab4a4be2ed qmllint: Re-enable warning about automatched signal handler
... and give a hint on what to do about it. In order to not duplicate
all the warnings from the importer, make sure it runs only once.

Change-Id: Ie2b314ff659664f7c84c20cc7971c094e15c59cf
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-11-26 11:57:48 +01:00
Ulf Hermann 6605839deb qmllint: Support opening the same grouped scope multiple times
Previously, we would only record the first source location for the
scope, which produced errors and crashes on bindings to any further
locations.

Pick-to: 6.2
Fixes: QTBUG-96147
Change-Id: I02e6a551f1eafb31ac7c49d3250d74e5a3842971
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-11-26 11:57:43 +01:00
Fawzi Mohamed 7f5db0b5e3 qmlformat: test normalize on some examples
runs the normalization (AttributesSequence::Normalize) on some
examples, and do not just test the AttributesSequence::Preserve
reformatting.

Change-Id: I7d53f84174e841de1d63e8d3e1bdc339cf727f5f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-26 08:48:20 +01:00
Maximilian Goldstein ff8139d23c qmllint: Expand qmllint library API
The API now allows for specifying the file contents yourself for either
on-the-fly editing or if you have your own caching scheme.
It's now also possible to access the logger directly in order to read
diagnostic messages instead of structured JSON output.

Change-Id: I4eb8440c7b25068cd09f28a5f3cbd0a318774522
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-11-25 10:03:46 +01:00
Andrei Golubev dce9a915d6 QQmlJSImportVisitor: record UiArrayBinding as binding
UiArrayBinding stores object bindings for list<Type> properties (where
Type is, or is derived from, QtObject)

Test the change both in qmllint (with an ordinary "it reports warnings
when needed") and by introspecting QQmlJSScope. In the latter case we
can also ensure that the bindings are recorded in the correct order

Fixes: QTBUG-93358
Change-Id: Ib5544ba339e22ea899191483a5ba53f755314daa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-24 19:51:02 +01:00
Ulf Hermann 52ca4efeb9 qmllint: Warn about lower case enum names/values
Those are invalid in QML, even if we know them ahead of time.

Fixes: QTBUG-98541
Change-Id: I677f4d8be29ea4ab7040faf9c54ae45cdad75cad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-24 19:44:50 +01:00
Maximilian Goldstein 650e6739c4 qmllint: Fix attached object reuse false positives
Previously the warning would be triggered even when no property is
accessed or only an enum access occurred. Since neither of these actually
cause the attached object to be created, do not warn in these cases.

Change-Id: I53d2886268e2364f2d9bc088e0ba02dc1cfe4ee3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-11-24 14:49:02 +01:00
Maximilian Goldstein 2a04222cfc tst_qmllint: Fix requiredProperty.qml test
The clean example for testing required properties was using the root
component which we do not check for required property errors, use
inline components instead.

Pick-to: 6.2
Change-Id: I945ed5c15334b7d88161dddd27b6962593184f9e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-24 14:48:56 +01:00
Ulf Hermann 269003ef96 tst_qmllint: Check that the output isn't duplicated
Change-Id: I21ab0ee6f01a8d677922e40a2b35de1990fc9dfe
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-24 14:47:54 +01:00
Andrei Golubev 57293e3f90 Further improve QQmlJSMetaPropertyBindings (2/N). Take 3
Make QQmlJSScope insert property bindings in the correct order.
We can do this by using some hackery:
- insert the element first through the QMultiMap interface
- query the non-const equal range and rotate first element to the end

The rotate is a bit slow, however, so let's do move left + copy-assign

Change-Id: I8f422c8a9105211fb016047c70b51b851c9873d8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-11-24 09:27:58 +01:00