We need to generate isList properties for those, so that qmlcachegen and
qmllint can handle them.
Pick-to: 6.4
Fixes: QTBUG-104129
Change-Id: I7e632279a605694c2fd5f583c8a6dcf9968eb634
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
There is an apparent problem in certain cases where using outer context
to fetch ids is invalid: the outer context is the *outermost* context,
meaning that if a type has a derived type in another QML document,
the derived type would place its own context as a QQmlData::outerContext
As a simpler solution, just remember the document's context in all the
objects within this document. This automatically works in derived types
since they appear in other documents with separate contexts
Pick-to: 6.4
Fixes: QTBUG-103956
Change-Id: I29420ff4962b485502d87b2d2ac2f89b9e0f5736
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
This symbolizes the last piece of QmlIR dependency that qmltc has.
We do still have some implicit dependencies on QmlIR, though, but
that should go way once the remaining prototype code's logic is
migrated to QmltcVisitor, QQmlJSScope and friends. This, however,
is not attempted here as the patch itself is rather large
In the process of switching to QQmlJSMetaPropertyBinding, observe
and fix issues in QmltcVisitor and surroundings
Pick-to: 6.4
Change-Id: I752b68a7f57baf354de16dc0bb466a3f693a4e49
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
The logic is misbehaving on multiple occasions. For instance,
same-named signal handlers in different scopes and script bindings
inside array scopes were wrongly handled. Fix that by revising
the mechanism of inner function computation
As a drive by, fix parseLiteralOrScriptBinding() to distinguish
translation bindings from script bindings (they are vitally
different now)
Extend the script calculation test in tst_qqmljsscope to cover
the findings
Pick-to: 6.4
Change-Id: Ic4cf0a4539f0d714a416b61f4635eb6494e89922
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Follow the policy of "good" QML modules where the module would reside
in a folder named the same way as the module URI
Somehow this is still not enough to remove an explicit
"-i <own qmldir>" workaround in qmltc compilation command
Change-Id: If1725ec03baf3690bb6cb8fc7876b082a155eaa2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
If the element type is unknown the list type is also unknown. This will
happen if we cannot resolve the type.
Fixes: QTBUG-103920
Change-Id: If1b05d99a1e64961981b5adb3974a51c11e776d2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
We can get into situations when binding creation is problematic
due to the relevant scopes being yet unresolved. In particular,
this happens when processing attached/group properties script
bindings
Avoid having this situation by postponing the actual binding
setting until after the relavant scopes are resolved (mainly,
the binding owner). However, do relevant AST order dependent
operations beforehand to avoid accidental errors
This commit amends 25098b7a4f
Fixes: QTBUG-103897
Change-Id: I671955dbe321d03e5f1ab9891cc79dc0a936deda
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Group scopes may be value types so they require access semantics
different from a default value
Ordinary scopes and attached scopes seem unaffected, only groups
are thus covered with an extra logic
Change-Id: Ia9012548a602ca7ca07296491d27a295f4455f91
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Whenever working with properties (reading, writing, aliasing, etc.)
of the type that has extensions, prefer the same-named properties
from extension objects over type-owned properties (this is the internal
QML mechanism)
To achieve that, we need to query the extension object:
* for Q_GADGETs use a dummy model of assuming we can cast the object
to the extension type and use that
* for Q_OBJECTs use a qmlExtendedObject() with additional logic of
figuring out which extension should be picked in each specific case
Create QQmlProxyMetaObject via a custom dynamic meta object API for
qmltc-compiled objects that are derived from base types with
extensions
Task-number: QTBUG-91956
Change-Id: I5e783768ae2abdb9dddf894de7e79960244352bd
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This is de-facto how it always was before
ff0b9ec6bf. As we plan to revert back to
the "original" behavior, document the FINALity of the properties so that
users know how it behaves (and we could not be held responsible for this
mess)
Change-Id: I4afed215fd66875821b7ce8d824b81782388324b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
As we can store sequence types in QJSValue, we should be able to
retrieve them, too.
Move the declaration of the QV4::Sequence struct into a header to make
it less of a hassle to identify sequences.
Change-Id: I3e45bfe193c669107f90cd6c502765c0c9f60fb0
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
[ChangeLog][CMake] The qmltc compilation functionality provided by
qt6_target_compile_qml_to_cpp() is merged into qt6_add_qml_module()
command and is available through ENABLE_TYPE_COMPILER argument. The
qt6_target_compile_qml_to_cpp() function does nothing and is left
only to highlight that users must migrate away from it.
Fixes: QTBUG-100215
Change-Id: Ie7d6b82564dff86176194fce35039ba0d93c0977
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This reverts commit ff0b9ec6bf.
Reason for revert: QTBUG-103881
Change-Id: I7e333ec854e81fb06f1f84b77125edc78bb181e6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
If the debuggee somehow manages to ignore our kill signal, the QProcess
dtor will hang. Let's rather crash in this case, so that we see when it
happens.
Task-number: QTBUG-101678
Change-Id: Idc72412925244acfdb1dfdeec07369d5fb271080
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
URLs with two slashes after the colon are generally _not_ local as they
contain an authority. However, file URLs with two slashes are
interpreted as "special" paths by QUrl::toLocalFile(). Therefore, we
accept them.
URLs without slashes after the colon can be local files. They denote
relative paths or special android resources then.
Pick-to: 6.2 6.3
Fixes: QTBUG-102944
Change-Id: Iaab3d7501b631e88ee8c1d93f1de8149ba60a5c4
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
In JavaScript the [] operator on strings returns a string. QString's
operator[] returns a QChar, but we can easily create a string from that.
Fixes: QTBUG-103371
Change-Id: Id5c960f00ecc7a5dfe30ccbcaac3ffb2a30308b9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Instead of the storedType hack in the type resolver, properly declare
the type LoadElement can return: A merge of undefined and the actual
type. This way we can choose the best concrete type to use for this
independently (and optimize it later).
Task-number: QTBUG-103529
Change-Id: I17b1f835f6a893ec843a90491e92f72ecb2e87fe
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Previously we just crammed it all into one line.
This made debugging really painful. You either had to properly cut out
the source code, remove all the additional quoting and reformat it or
run qmllint manually to get proper formatted output.
This way you can actually debug these issues without resorting to any
external tools.
Change-Id: Iafdaaaa0ef7b96e70057b9b637b7c8f051d9e43a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
If components are bound we can assume the IDs of outer components are
reachable.
Fixes: QTBUG-102806
Fixes: QTBUG-101012
Change-Id: Ia26d3963d6c2fb9698debb12f9c655c5522f81ea
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Clone the full-ish meta object hierarchy when dealing with extensions:
that way we guarantee that shadowing works correctly both ways -
extension properties can shadow type properties AND type properties
can shadow extension properties (the latter happens when extension
belongs to a base type). This was impossible before since we would
always put extension proxies on top of the meta object chain,
regardless of where in the chain extensions are located. Consider:
"C -> B + ExtensionB -> A + ExtensionA" is interpreted as
(old) ExtensionB -> ExtensionA -> C -> B -> A
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^
cloned meta objects static meta objects
(new) C -> ExtensionB -> B -> ExtensionA -> A -> C -> B -> A
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^
cloned meta objects static meta objects
One can notice that we now clone _more_ meta objects: this is to
be able to to create a chain with correctly ordered properties
Unify the proxy data creation under QQmlMetaType::proxyData()
Update QQmlProxyMetaObject which now has to deal with different types
of proxies: not only extensions but also "cloned" self. CustomCall
metaCall() of QQmlProxyMetaObject is also adjusted to ignore
non-extensions
Change-Id: I40e1547a9c05a8504ab98bc06a6bc412a2460783
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Previously the extension's property revision would make
the property unusable since extensions would've been skipped
from property cache construction w.r.t. revisions
This is due to the meta object cloning that we do for
extension types (since we put the cloned meta object on top
of the meta object hierarchy for the QQmlProxyMetaObject).
Once cloned, the meta object has no associated QQmlType
anymore and we need one to deal with revisions. Overcome this
by registering the cloned meta object in the QQmlMetaTypeData
From now on, the cloned extension meta object has an
associated QQmlType, which is the *extended* type, NOT the
*extension* type
Change-Id: I4a6a4380278b80e49e1b9874dd458183667e5cb5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
If a component is bound to a file context, we can be sure that the IDs
present in the same file will be accessible to bindings and functions
inside the component. We will need this to allow such bindings to be
compiled to C++.
[ChangeLog][QtQml] You can now bind components to a file scope. This way
you can make sure IDs in the file are accessible to the components.
Task-number: QTBUG-101012
Task-number: QTBUG-102806
Change-Id: I290a61752b4b02e13f0bb0213ba3f871bdb95260
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Introduce a compile-time procedure to distinguish types without
extensions but with base type extensions from types with direct
extensions. Previously, we would have treated both cases the
same due to the C++ mechanism employed to mark a type as
extension-containing
As a drive by, make QQmlMetaType::clone() use class name of the
extension when we clone the extension
[ChangeLog][Important Behavior Changes] A derived type is no longer
considered to be extended itself when only its base type is extended.
Instead, the extension only exists on the base type.
Change-Id: I74092a5f88cad09c1e07626ae90bb986db0da73d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Added moduleName and qualifiedName to QQmlJSScope. Those
properties are written in the scopes after they were
loaded by readQmlDir.
Fixes: QTBUG-103299
Change-Id: I3b2c68c43c3bf0ac6cf801b0e54cf4b412b4d4e5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
We previously hit an assert / crashed if we saw an empty script binding.
Fixes: QTBUG-103707
Change-Id: I117d984a7d315ecf860d2ada5568637d154ae083
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
QQmlListProperty is only for object lists. Object lists are the only
thing we can use in LoadElement for now.
Fixes: QTBUG-103529
Change-Id: Ia120addcfc0afcbf1815d1bd9671f20df8334744
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Previously we would often suggest to add an id to the view containing
the delegate so you could access the model that way which is very
misleading and might be especially bad as an automatic suggestion.
This change now recommends that the user adds a required property,
although we currently lack the logic to properly insert one for the user.
Fixes: QTBUG-103101
Change-Id: I4cd858ff6617d12b9abf070f524dc626d699e4f1
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
The TimeZoneSwitch class was setting the doChangeZone flag incorrectly,
so it was actually trying to change the zone only for "localtime".
This patch fixes the issue.
With this fix applied, the test started failing on some OS that fail
to change local timezone, so skip such input data for these
configurations.
Fixes: QTBUG-100014
Pick-to: 6.3 6.2
Change-Id: If39a15fe1008211a940174fdc3aa5209df34c115
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This change reimplements the PropertyPass to be based on bindings
rather than on just iterating over elements. This is a lot less
cost intensive than iterating over all properties regardless of
whether they are actually used. You may still achieve the same
thing with the more flexible element pass, just with the benefit
that you can choose what properties you want to iterate over
instead of iterating over all of them.
To demonstrate the passes usefulness the existing attached property
warnings are ported to use the binding pass and can now also warn
when an attached property is read or written in a context where
it's not supposed to be used.
Fixes: QTBUG-102860
Fixes: QTBUG-102418
Task-number: QTBUG-102859
Change-Id: Iea87a1b05b954429b8bf00fd27b60487940af679
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Implements anchor related and back/left/behind combination warnings.
Also adds a quality-of-life improvement in tst_qmllint where we print the
line when an expected message is missing.
Task-number: QTBUG-102277
Task-number: QTBUG-102859
Change-Id: I56068c75e3c6187845b079a6689debefa363a5e4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Introduce a private version of qmlExtendedObject() that returns an
index-based extension (where 0 represents an extension on the leaf type
and N represents a (N - 1)th base type's extension)
Teach QQmlProxyMetaObject to distinguish different extension proxies.
Its custom metaCall can now query up to 128 extensions (should be enough
for the user needs)
Change-Id: I5520a1e84501f1f9fe6a8e77d8269009a12c255c
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
We can have QQmlDelegateModel pick specific roles from model items. That
can easily be done for variant maps, variant hashes, objects and
gadgets. We would like to do it for anything that has a
QMetaAssociation, but as we cannot get to the original type at that
place, it's currently not possible.
The special case about variant maps with exactly one item in variant
lists is clearly insane and therefore not included in the
generalization.
This requires some cleanup in the QQmlGadgetPointerWrapper. Passing the
wrapper itself to QMetaProperty::read() has always been a rather obscure
way of reading from the gadget.
Pick-to: 6.3
Fixes: QTBUG-102983
Change-Id: I84ecef980783e7137aa4d77070ddce47b6ead260
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
QML_{NAMESPACE_}EXTENDED and QML_EXTENDED_NAMESPACE are supposed to
behave differently when it comes to visibility of properties, methods,
etc. Thus, make it so by actually using different class infos and
updating QQmlJSScope. Use a HasExtensionNamespace flag to differentiate
between extension and extension namespace (whenever one of them is set)
Update the internal search routine that traverses the base types and
extensions of the given scope
Change-Id: Ifafbb22f831f5b128e431a3e65c514ffdf65eb73
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Do not go over extension's base types since this is not how the engine
logic work. Instead, only assess the direct extension type when
traversing the base type hierarchy. The special cases are value types
which still need base type extension traversal (e.g. due to Number
and NumberPrototype extensions on primitives) and QObject type itself
(we expect to see ObjectPrototype properties / methods of it)
Pick-to: 6.3 6.2
Change-Id: I92ba979202b33f16e1a7b948d4f1e79df37f2669
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
When converting a JS value to a variant, if we notice that we get a
QJSValue again, there is no point in trying to convert it further. We'll
just run into infinite recursion.
Pick-to: 6.3
Fixes: QTBUG-102545
Change-Id: I0a40e21287e5460e5e214101aabe8d2b4bf0afad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
The name of the module's folder should match the URI and
application binary dir should be provided as an extra import
path for the module to be discoverable
Change-Id: I00d67593d18dc86c0929f8a64b2c165221a4758a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Grouped properties do not bind to a default property and they are not
object definition scopes. Fix the subtle issue where we'd do the
opposite for `group { ... }` syntax
Submit the tst_qqmljsscope changes that made the issue visible
Pick-to: 6.3
Change-Id: I314b19d5cad62f70146d228e5402c9fc73b309ad
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Qt/QML allows marking a type with QML_EXTENDED_NAMESPACE(Type) where
Type is a Q_OBJECT. In this case, we have a Type-specific meta
object but do not have an extension function to create the object of
that Type with, causing us a subtle runtime crash. The crash in fact
happens when we attempt to access a shadowed property through the
extension object (which surely fails since there's no extension object)
Fix this by excluding properties and methods when cloning the metaobject
for the proxy if we know that the proxy cannot be created. This somewhat
matches what the documentation says about QML_EXTENDED_NAMESPACE:
When we have a Q_OBJECT/Q_GADGET, methods and properties of that are not
exposed
As a drive by, add the same check to the QQmlMetaType::proxyData().
While untested, this seems logical since the proxy data assumes valid
creation function in this case as well
Fixes: QTBUG-103081
Change-Id: I63c6e535d4df5169e0279eb2f588593f43a70640
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
a) Test-document the behavior when we have QML_EXTENDED() with a Type
which itself does not provide any properties but instead has a base type
that does. In this case, we won't consider base type properties from
extension in the meta call resolution, using the non-extended properties
instead
b) Test what happens in various cases of property existing only in
extension type
Change-Id: I5340e8d6606b2f170e9766716871c5a6a8cba948
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Previously we only warned when a component we were linting contained all
of the anchor properties causing a conflict. Now we also warn if the
combination is created across multiple components or files.
Also makes QQmlJSMetaPropertyBinding record undefined literals as they are
needed to tell whether a property has been reset somewhere in a type.
Task-number: QTBUG-102859
Change-Id: I04012848d0526cce6aea34036c6b2e0daf79cf9d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Introduce an alias resolution procedure to query the origin
property and its owner for a given alias
Add alias compilation to the "proper" qmltc code and remove
the equivalent one from the prototype
Change-Id: I55bc1e3e6206b4cfce259526d1bc2813e8ea7cfb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
QLocale reversed the order of languages returned from uiLanguages()
recently. Adapt the test to this change.
Fixes: QTBUG-103026
Change-Id: I471351494bd56e48d1cf4bee3f6f27a786c5b107
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>