We can access the same QObject in const and non-const contexts. Both
should be possible. Store the const objectwrapper in
m_multiplyWrappedObjects. That's somewhat slow, but const QObjects are
rather rare.
Pick-to: 6.4
Fixes: QTBUG-98479
Change-Id: I047afc121f5c29b955cd833e0a2c8299fc52b021
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Previously we've assumed the whole allocation can be used, even though
the first and the last page are actually not usable. This makes a
difference when the size of the guard pages grows, such as on macOS,
which these days has 16k pages.
Add the extra guard page size to the amount of memory to be allocated in
order to fix the calculation.
Pick-to: 6.4 6.3 6.2 5.15
Fixes: QTBUG-93188
Change-Id: I0ebece94449da3127e9a78a19d8a22722ad8d698
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Otherwise the property cache might be null and lead to segmentation
faults, e.g. when declaring aliases in qml.
Fixes: QTBUG-106256
Change-Id: I568c973e1ba00531fbe22a41e2c6c3c09dfc2f02
Pick-to: 6.2 6.3 6.4 5.15
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
The test has been fixed for some time now but the Q_SKIP() was not
removed yet (I guess the merge algorithm decided to keep both the Q_SKIP
and the improved test).
Amends d26675105b.
Change-Id: I6edd6fa1c3dca703f26adb8854155681f3872e5b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
When we use an attached object as an argument to a function call, we
need to properly extract it from the QmlTypeWrapper. Before this change,
we simpley left the argument pointer as null, which lead to subsequent
crashes when it got dereferenced.
Moreover, treat passing namespaces to functions expecting a QObject as a
TypeError, by returning false from CallArgument::fromValue (used to
crash for the same reason as with the attached object case).
Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-106119
Change-Id: Ifa6a32e20a29935aff1f265eb0edd3e35ea1c11b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
So far, you could only use them from pure JavaScript programs. Also, fix
re-exporting parts of native modules.
Fixes: QTBUG-105901
Change-Id: I170017083284e6457b1aa0c6e606fd26227edae3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Test support for generalized group properties in qmltc.
Also, force group property bindings to be deferred when they belong to a
generalized grouped property, while "not-generalized" grouped properties
never are deferred.
Fixes: QTBUG-105378
Change-Id: Iadc64d7033f9446ccf53e305d8831c7d348f257c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This is basically the same as QTBUG-105204, only with the QML engine
being involved.
Fixes: QTBUG-104982
Pick-to: 6.4 6.3 6.2
Change-Id: I5afaadedcd7af41198702a8f2331703b4f6ef2e7
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Up to now, just the test result (pass or fail) was saved during testing.
Add an errorMessage in the test result that is retrieved from the
engine and print it out when a test is failling.
Fixes: QTBUG-106096
Change-Id: I73f9f7daaa92a942d89391043682d8d9ebbcdfa3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This mirrors 9d22088d93, which removed the
warning from the engine.
Pick-to: 6.4
Task-number: QTBUG-106069
Change-Id: Ib714bfbd251dcf30becd920c85ac65aceab43707
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Add tests to qmltc to see if it behaves well for aliases to different
kinds of properties, and compares if the engine shares the same
behavior. Same for the attributes in the QMetaProperties.
Changes:
* add some more MOC information to aliases
** always add NOTIFY to aliases (like the engine does)
** always set DESIGNABLE to false for aliases (like the engine does)
** always set CONSTANT to false for aliases (like the engine does)
** always set STORED to false for aliases (like the engine does)
Test if:
* default aliases works when compiled via qmltc
* attributes of aliases are set correctly in QMetaProperty and compare
it to the attributes of the QMetaProperty obtained from the engine.
* aliases can read/written/reset/notified
Fixes: QTBUG-105708
Change-Id: I66b9c43c8c8de3dbd2b33d5ce15cd42ffb377ce7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
We generally have to do those calculations in double as we must not
collapse inf into 0.
Task-number: QTBUG-100242
Change-Id: Iaf8082160a1ab25060c131ee1a5fa259bbd31214
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
With a particular nefarious combination of Q_GADGET and inheritance from
QObject you can make QmlCompiler believe a type is a value type even
though it is actually an object type. We never want to touch such a
thing.
There was a safe guard against this when looking up the type from the
scope, but by putting it in a type namespace you could circumvent it.
Refactor the code to apply to both cases the same way.
Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104556
Fixes: QTBUG-105608
Change-Id: I8a690e2b6f78fcaba0911a93504cde0d2c7dde0d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
"static" is a keyword in the context of JS classes, no matter how deeply
nested. Therefore, keep track of the nesting level.
Switching the keywordiness of "static" off during method definition
parsing makes no sense as the standard doesn't mention such a thing.
Method bodies are strict code where you cannot use "static" as
identifier. Methods and properties can be called "static" no matter if
static is a keyword or not.
Pick-to: 6.4
Fixes: QTBUG-96631
Change-Id: Ia09e52fe2ae72721fe1c8a9b95899a31095db988
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Some of the math operators were still missing. Add them and test them
all.
Since the "runInterpreted()" test function takes too long now, split the
qmlcppcodegen test in two: One that runs in compiled mode and one that
runs in interpreted mode.
Fixes: QTBUG-105188
Change-Id: I4b641d5e51b5a7e2a9254be40f257d7b249deb13
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
There were two problems:
a, We need to allow recursion when querying for enums. Otherwise we
cannot find enums in the same document.
b, when the enum resolution is done in the validation phase, we cannot
query the current document's QQmlType for enums, yet, as it's not
finalized. However, the QQmlPropertyValidator has the
QQmlPropertyCache we're looking for in that case.
c, As a drive-by, fix the excessive conversions between QByteArray and
QString.
Pick-to: 6.4
Fixes: QTBUG-95864
Change-Id: If0d2687986e1483a27ce11373a204235b92a6efd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
You can always access enums of attached objects, no matter what other
rules apply to the attached properties.
Pick-to: 6.4
Fixes: QTBUG-105590
Change-Id: I07878d8efe63468539168aa2c2842e3159ed2090
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
For several reasons:
* It was renamed to QT_DISABLE_DEPRECATED_UP_TO
* Its value will be propagated from the general Qt build
Task-number: QTBUG-104858
Change-Id: I90c92dc05b884f6408467c573181c00f8e00e6b3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
... and use nativeTerritoryName() instead.
This allows to build the tests without deprecated APIs.
Task-number: QTBUG-104858
Change-Id: Ia66f2e05fd033e1ca6da93b58dbcbccae3448ec5
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Protect the usage of deprecated APIs by #ifdefery, and
also suppress the deprecation warnings for it.
This allows to build the tests without deprecated APIs.
Task-number: QTBUG-104858
Change-Id: Ied0aecc3fdf07db436ac11e70d0fa78e6a96dc1d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
ArrayBuffer constructed from en empty QByteArray are detached,
calling byteLength should not throw an error.
According to ECMA specifications the `byteLength` property
of a detached ArrayBuffer should retrurn 0.
See https://tc39.es/ecma262/multipage/structured-data.html#sec-get-arraybuffer.prototype.bytelength
[ChangeLog][QtQml][Important Behavior Changes] ArrayBuffer.byteLength()
now returns 0 on detached ArrayBuffers, conforming to ECMAScript 2021.
Fixes: QTBUG-103925
Change-Id: Ib1c325eff25459980e10a1f3cd9fb7cb3b8eb5e5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Implement and test support for translation bindings in qmltc:
* qsTr()
* QT_TR_NOOP()
* qsTrId()
* QT_TRID_NOOP()
Not compiled by qmltc, but instead interpreted as script bindings:
* combinations like qsTr(qsTr())
* qsTranslate() (as in qmlsc)
* QT_TRANSLATE_NOOP() (as in qmlsc)
Add the *.qm files directly to the resources as qt_add_translations() is
not available from qtdeclarative (the cmake function lives in qttools that
depends on qtdeclarative).
Fixes: QTBUG-104637
Task-Id: QTBUG-105346
Change-Id: Ia9433c2bcef01f3486358d963059d9779c67708c
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
The Qml lexer was not restartable, make it so that a line can be
parsed independently from another.
This is a requirement for efficient indenting and highlighting.
Old approach in creator used a separate finite state machien "scanner",
now it is possible to use the same lexer as the parser.
One can "checkpoint" every few lines, and restart the process form the
line above the change, and stop when the status is the same as before.
Change-Id: I72a13a767ac7adfe103e56e60902e61c88e4fd82
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
This test fails the dependency update on macos x86_64 platforms
but is just checking if/when a qFatal error is thrown. Therefore, it
is blacklisted.
Change-Id: Ie08c24e0b00aedbcf40b5b51191a0e4a6180a1dd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
If the user used for(let x;...) we need to preserve the let and must not
change it to var.
Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-105361
Change-Id: I49fc3797505b569cc9b8a9138dd57ec7e70d3eb9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
For objects with circular structures we generate a proper error message
and fail earlier. For objects with excessive recursion we throw a range
error rather than crashing.
This behavior is modeled after node's behavior in such circumstances.
We use the existing stack overflow detection to determine when to throw
the range error. Testing shows that on windows the limit was
insufficient. Lower it.
Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-92192
Change-Id: I25dd302f65f359111e42492df3c71549c4ed7157
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
test that warnings are emitted for duplicate exports. Also, added
missing dependency in CMake for tst_qmltyperegistrar.
Fixes: QTBUG-103189
Change-Id: I7e26cd0de2f9a404c7c02822baef6eafa4f51c11
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Just create a dummy type that has the actual name. To make that
possible, export the property cache creator's class counter to the
autotests – otherwise, we cannot know the name of the actual type, as it
would depend on the order in which the tests run.
Change-Id: I36b24183fbd041179f2ffffd17026b224c9737fa
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This fixes an oversight where in case of half-resolved grouped
properties we would forget to add the bindings to the "pending" list.
In addition we would fail to resolve their property caches later on.
Pick-to: 5.15 6.2 6.3 6.4
Fixes: QTBUG-94983
Change-Id: I88bd0ce56464438d2a105e5ed426e002495cc016
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
All of those are legal in ECMAScript, and so we need to support them in
script bindings. As we have stricter rules for literal bindings, add an
extra method there to check for what QQmlPropertyValidator does.
Pick-to: 6.4
Fixes: QTBUG-105252
Task-number: QTBUG-105188
Change-Id: I0621b2c3aa196414f669873e93670557284a8bca
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
We need to preserve them as they notify us about protoId related
changes. In order to avoid wasting heap space in case many properties
are added and removed from the same object, we put a mechanism in place
to rebuild the InternalClass hierarchy if many redundant transitions are
detected.
Amends commit 69d76d59ce.
Pick-to: 5.15 6.2 6.3 6.4
Fixes: QTBUG-91687
Task-number: QTBUG-58559
Change-Id: I3238931b5919ed2b98059e0b7f928334284ce7bf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
We need to use the same algorithm as for Math.pow(...). Since we have
jsExponentiate() now, we can use it in all those places. The strange AIX
special case is definitely not useful anymore.
Task-number: QTBUG-105188
Change-Id: I43a251c71f1b547ad36855ac197080bfea8c94e3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
As a drive by, propagate CONSTANT attribute through the .qmltypes file
and qmlcompiler library
Task-number: QTBUG-91956
Change-Id: I5802fa29ddedcdadae3e505efca0c4fb4d6b2593
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Explicit components could be accessed by id like regular objects. Make
this work in qmltc by revisiting the object creation procedure - store
explicit components along with pure QML types in
QQmltcObjectCreationBase:
xxxxxxxx x'x'x'x'x'|yyyyy...
^ ^ ^
pure explicit types from base class
types components
As a drive by, fix unset required property in one test file and add a
bunch of other test files to the initTestCase() check
Pick-to: 6.4
Change-Id: Ibdaa430d692c81101853f51dae1da462a57a9980
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
There's no reason to have the location in the warning.
It already gets printed by the logger.
Change-Id: Ia1335cab6324587a4e35a25bbb46537f358e1bd7
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Fix subtle issue where alias assignment would cause qmltc to generate
direct property set code (doesn't work for aliases since those do not
have "real" properties)
Remove now redundant TODO and identical code path when compiling alias
assignments on types with composite bases (used to work poorly during
prototype times)
Pick-to: 6.4
Change-Id: Ifacf5872ff5432a748fb1ec16c300ec844d65e9a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
The qmlqtimeexampleplugin exists as a target name both in examples and
in a test; rename the one from the test.
Change-Id: I21b68f7d6228ceaee49ba28e55516b5b10ffce3a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
So far we have only accepted QQmlListReference. However, we can also
pass a QQmlListProperty around as value.
Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-105137
Change-Id: I7d4cd3048b62594298f91013c4cda5ec864a28df
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Fix subtle issue where an import namespace would become part of the
generated C++ class name without modifications (so with '.'). Preserve
the namespace for the time being just to make the generated code more
verbose (e.g. consider mixing QQ.Text and ZZ.Text in the same file)
Change-Id: I3d409988ae136c272aac6a4eab287a7221f88450
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
qmltc needs to compute a QMetaProperty index ahead of time when creating
property bindings. This procedure has to acknowledge that extensions
exist
Change-Id: I7bf6b6c558ce78e0fec5ee880bc4d39a79fe5640
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
In case of a JS context, we need to do the JS lookup early in order to
override imports with locally defined functions.
[ChangeLog][QtQml][Important Behavior Changes] The precedence between
imports and locally defined functions and variables in JavaScript files
has been fixed. If you import a JavaScript file from a QML file, the
functions inside the JavaScript file should obviously override anything
imported from the QML context. This behavior has been restored.
Pick-to: 6.4
Task-number: QTBUG-91687
Change-Id: I119e3109f96ffad7455daaf1a5f17bad31fa8e33
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
This change allows for modules to be linted via the -M flag.
This will check whether an individual module has a sound qmldir and
qmltypes. It will also verify whether all its types and the types of
properties can be resolved.
It does not lint individual QML files.
[ChangeLog][qmllint][New Feature] Individual modules can now be linted
via the -M option
Fixes: QTBUG-103264
Change-Id: I3ced4b0bc05358e9216c9819f1dca67af909405e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Group and attached properties have QmlIR::Objects associated with them.
However, qmltc's object index calculation ignores groups/attached types.
Fix this, making object index calculation aligned for implicit
components
Fixes: QTBUG-104780
Pick-to: 6.4
Change-Id: I377d3eab714d0e9618ac2ef84c2738b45ad3b6cc
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>