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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Declare the signal handlers as functions.
Change-Id: Ie583a123054cbc090245ccc55e7de9ac83397372
Pick-to: 6.2 6.3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
You really should not mess with that after creating the property cache.
Change-Id: I070200772475bb67f539dbbd85a298020b14ca79
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Document some extra behavior details through tests
Pick-to: 6.3
Change-Id: Id05da7983406a0a61e78496a8e6483e10a7c38d1
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Ports all the remaining tests that can be ported to use the library.
Change-Id: I030a97fc3957c2f4f5e3bdd98ce9d5b0b87e5638
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
[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>
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>
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>
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>
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>
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>
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>
We do want to see the output if the cleanQmlCode test fails.
Change-Id: I6b7e9d3412af9fffac68d2e394418de2faf09626
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
...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>
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>
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>
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>
We want to be able to skip it.
Task-number: QTBUG-98305
Change-Id: Ibb0293d348f2828a28be4c458cf955b4cc706caa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
... 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>
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>
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>
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>
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>
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>
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>
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>
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>