Commit Graph

9957 Commits

Author SHA1 Message Date
Ulf Hermann 759b8383d7 tst_qmlcppcodegen.cpp: Restore ordering of functions
We want them alphabetically sorted so that we minimize merge conflicts.

Change-Id: If6509fb1d196a10898fd6d9a5f51a9da678ad3c9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-15 14:13:32 +02:00
Ulf Hermann 269afdcb7c Fix disambiguation of file-selected components and scripts
In order to choose the right file-selected components and scripts when
resolving types we need to drop all but the "base" ones from the qmldir.
This has to be done right after parsing the qmldir, but only at run
time. At compile time we need the extra information to determine that we
cannot compile any access to such files to C++.

Pick-to: 6.5 6.6
Fixes: QTBUG-113940
Change-Id: I734b865202b6241d5dd60c134214bdbe09ea10f4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-15 14:13:31 +02:00
Sami Shalayel a1ce0596e5 Replace signal name manipulations with QQmlSignalNames
Remove custom implementations found in qqmljs* and use the
static helper methods from qqmlsignalnames_p.h instead. This sometimes
requires to move some code around to avoid bugs with property that do
not have letters in their name.
Add a warning in the JS implementation of the SignalSpy.qml that the
used heuristic might fail on certain signal names.
Add tests in in tst_qqmllanguage to see if the property change handlers
work correctly for weird names.

Change-Id: I4dc73c34df7f77f529511fa04ab5fcc5385b59fc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-15 12:13:31 +00:00
Amanda Hamblin-Trué 8d6f9e716d tst_bindingdependencyapi: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I467b54eee593f0b3b47788d83ac63cab6877d03f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-15 10:31:47 +02:00
Amanda Hamblin-Trué 2ef3e2c34f tst_qqmlenginecleanup: Clean up memory management
Task-number: QTBUG-115222
Change-Id: Ifc526a17039662c69b16e115133271c1419fd3b6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-15 10:31:42 +02:00
Amanda Hamblin-Trué 1284917e72 tst_qqmlmoduleplugin: Clean up memory management
Task-number: QTBUG-115222
Change-Id: Ie0faf6d29e9d76abe72c9d7a0600b25a7fd47d14
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-15 10:31:18 +02:00
Amanda Hamblin-Trué 3e79bfacee tst_qqmllanguage: Clean up memory management
Task-number: QTBUG-115222
Change-Id: Ib2797279dccd82b255615815f328d9245e13fda7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-15 10:31:14 +02:00
Laszlo Agocs bd71e82c2f Add QQuickRhiItem
Try to follow the QRhiWidget API in most ways.

Implies that the rhitextureitem example is repurposed
to be the QQuickRhiItem example.

The qquickitemrhiintegration autotest is repurposed as
the qquickrhiitem autotest.

Task-number: QTBUG-113331
Change-Id: I045d87f82ace07c8571c72c78e193cd5201cad69
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-08-14 17:03:42 +02:00
Joshua Goins 08667fa4af qmlformat: Don't add unnecessary space in target bindings
qmlformat was erroneously adding an extra space in target bindings like
"Behavior on opacity {". The extra space is removed, and the tests are
updated to prevent regression for this behavior.

Fixes: QTBUG-114801
Pick-to: 6.5 6.6
Change-Id: I79f563e40c75a325ab13f1fbffd73daa71fe1ec9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-11 14:10:00 +00:00
Ulf Hermann 973eb4dd55 qmltyperegistrar: Keep types sorted while processing them
If we mess up the sorting we may not be able to find types afterwards.
Unfortunately we sometimes realize that extra types have to be added
during the analysis.

Pick-to: 6.6
Change-Id: I80617c5c55383fa1e884bdf4182c79b10581467e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-11 16:10:00 +02:00
Ulf Hermann 4349ec1412 qmltyperegistrar: Fix sequence registration for builtin value types
We need to accept the sequence value type even if we cannot find it in
the type descriptions. It may be a builtin after all. Once we have
structured information on our builtins, we can drop this again.

Amends commit ad88383b46.

Pick-to: 6.6
Change-Id: I52cd6fac0c5e73c2509f5848284e9cad91781abb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-11 16:10:00 +02:00
Sami Shalayel a130481af2 qmlls: check user-supplied names on renaming
Implement the checking of user-supplied names for renaming operations
in QmlLSUtils and qqmlrenamesymbolsupport.cpp

Add a helper method QQmlLSUtils::isValidEcmaScriptIdentifier that runs
the lexer on an identifier. Reject identifiers that do not parse as
T_IDENTIFIER, like keywords and invalid unicode escapes, for example.

Extend QQmlLSUtilsExpressionType to contain the name of the current
object.

Drive-by change: fix a off-by-one bug in the lexer, where files (or
identifiers, in this case) could not be lexed when they were ending with
an unicode-sequence.

Also, do not crash on JSIdentifiers without semantic scope in
resolveIdentifierExpressionType.

Add some tests, and fix a warning about positionAfterOneIndent
not being used in tst_qmlls_modules.cpp.

Add QQmlLSUtils::isChangedSignalName next to
QQmlLSUtils::isChangedHandlerName, and QQmlLSUtils::isHandlerName
and add tests for all three.

Fixes: QTBUG-114951
Task-number: QTBUG-114788
Change-Id: I0f1a544b70dfb69bca4aef355a8a8658f1d23081
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-10 19:55:40 +02:00
Santhosh Kumar 62014e9cec Remove bounding behavior of popup for negative margins
The popup behavior is inconsistent when its moved or repositioned over
the edges of the bounding window. This happens for negative margins,
as its made to bound within the window (while respositioning using
QQuickPopupPositioner::reposition) only on left and top edges of
the window during resize, but its allowed to move outside the bounding
window on right and bottom edges. This pushing of popup within the bound
can also sometimes leads to infinite polish issues (for the qml
configuration as mentioned in the bug report QTBUG-107473).

This patch set removes this constraints for popup to move beyond edges of
the window (through QQuickPopupPrivate::relaxEdgeConstraint) during
resize. By default, this flag is disabled, means those controls which
inherits from popup restricts by itself not to move beyond the edges
during resize.

[ChangeLog][Qt Quick Controls][Popup][Important Behavior Changes] The popup
default margins (-1) earlier was constrained on left and top edges, but
allowed to move beyond right and bottom edges. The behavior changed now to
relax this constraint and move beyond all edges. Also to be noted, edge
constraints has been relaxed only for Popup and controls inheriting from
popup (such as drawer, menu) still follows earlier behavior.

Fixes: QTBUG-107473
Fixes: QTBUG-77647
Change-Id: Icf0dc909559b5059a7371a6455a15ffc84e9b77d
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-08-10 15:54:22 +02:00
Mitch Curtis 2cf897f2a1 SwipeView: reposition items that aren't visible after startup too
7a5bbc2315 repositioned items upon
startup, but didn't account for items added afterwards. Do that here
so that semi-transparent pages don't show pages beneath them.

Fixes: QTBUG-115468
Pick-to: 6.2 6.5 6.6
Change-Id: If5ca587a6c14ddae5108c0a45d13fa2d290d1865
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-08-10 16:09:48 +08:00
Mitch Curtis 08b2302310 SwipeView: ensure items fill the bounds
Taking the translucentPages component from
SwipeView::test_initialPositions into a Qt Quick app and running it
showed that the Text items weren't actually filling the SwipeView. The
documentation states:

"SwipeView is populated with a set of pages. One page is visible at a
time."

The implication here being that each item fills the SwipeView, hence only
one being visible at a time.

It also states that SwipeView manages the geometry of items:

"Note: SwipeView takes over the geometry management of items added to
the view. Using anchors on the items is not supported, and any width or
height assignment will be overridden by the view. Notice that this only
applies to the root of the item. Specifying width and height, or using
anchors for its children works as expected."

So, this patch corrects the behavior and updates the test.

Pick-to: 6.2 6.5 6.6
Change-Id: I3425d4d028743f440f003e86ba009a2da7cca9cb
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-10 16:09:45 +08:00
Ulf Hermann 15b04e3f0c Re-enable qwidgetsinqml test
It got accidentally disabled during the qmake to cmake transition.

Change-Id: I27723a231e0a616f3b8de3db0fbe9a16fefac914
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-08-09 15:34:12 +02:00
Sami Shalayel 7f06b51616 qmlls: find id's, not the item around it
When you use qmlls's 'go to definition' on an id, it jumps to the
object around it, instead of the id-binding. For example:

```
Item { id:me }
// go to definition for 'me' goes to 'Item' above instead of the 'me'
// after the id!
function f() { console.log(me)}
```

Retrieve the correct sourcelocation from the Dom, fix the tests,
and remove one unused helper method in tst_qmlls_modules.

Change-Id: Ic25ceb8399cbc27e65574f2c3c7e71249bcac8f6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-09 15:34:12 +02:00
Edward Welbourne 919b51f32a Add missing null-checks in tst_qquicktest
Various tests dereferenced the QTextObject * of a create()'s return
without first checking that's not a crash. In one case, there was a
null-check, but someone had added a new dereference before it.

Change-Id: I358571c20c6a6f22b32f5ecdc9dade25b51545ff
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-09 15:34:12 +02:00
Edward Welbourne 23ef674454 Prefer QCOMPARE() for equality comparisons
It gives a more informative report than QVERIFY() would.

Change-Id: I3accda8bdd807175b234d0aa9bd553825b883e6e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-08-09 15:34:12 +02:00
Edward Welbourne 2455e27274 Purge stray horizontal space in XHR test data QML
Change-Id: If0d31d6e2deb68984b330beb16e8212fb6d67fd0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-08-09 15:34:12 +02:00
Edward Welbourne c3d73e8645 Correct an inaccurate comment in XHR test-case for repeated headers
Setting the same header repeatedly appends values to the header, as
the test-cases' expected output indeed shows, so don't claim the last
setting over-writes all earlier ones. Reflow in the process.

Change-Id: Ib21d218e5f762c3842aa03d380ed795023e5434d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-09 15:34:11 +02:00
Edward Welbourne d0a2f511f3 Clear out some locale-dependencies from XHR unit test
None of these tests care about Accept-Language, which
QHttpNetworkConnection sets automatically based on the system locale,
so testing for it (by including a line for it in .expect files),
setting it and skipping tests due to its "locale-dependence" were all
unnecessary. Just tell the test-server to {{Ignore}} the value of the
header.

This failed on Android due to one of the data files being unavailable,
so make access to that a precondition of its test.

Pick-to: 6.5 6.6
Change-Id: I560ead8b3ace6a5df173d96aea10f8dac3ed1124
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-08-09 15:34:11 +02:00
Santhosh Kumar 5ebed8ff9e Fix scroll wheel issue for top item with overlay as parent
The overlay filters wheel event for the popup item as part of patch set
caca7d7d4f. These events are consumed by
modal popup when the top level item is not its child. In a case, where
top level item is a child of overlay and stacked higher than popup, the
wheel event should be delivered to the top level item.

This patch set validates item at the top is child of overlay or popup
item and deliver wheel events accordingly.

Fixes: QTBUG-113842
Pick-to: 6.6 6.5
Change-Id: I2d27c09738742ef5ae25e42eca3747f1631baa6c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2023-08-09 15:34:11 +02:00
Mitch Curtis 15894c3ca7 Allow customization of native Dialog and DialogButtonBox
There's no harm in customizing these, and especially the contentItem
and footer need to be customizable, as that's where the content and
any customized OK/Cancel/etc. buttons go.

This fixes warnings in the testbench manual test.

Currently only the macOS styles has implementations of these
controls.

Pick-to: 6.5 6.6
Change-Id: I09678c777088786961583724d68dc2c3f6d90895
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-08-09 13:12:04 +08:00
Ulf Hermann 9599f4c553 QML: Allow conversion from JS Array to QByteArray
Since QByteArray is sequentially iterable and we allow any sequentially
iterable type to be constructed from a JS array, we also need to allow
this.

Pick-to: 6.6 6.5
Fixes: QTBUG-115733
Change-Id: I6ffd5eaad0e587ea1cafbe0c1b0179202f3f28cf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-08 21:13:06 +02:00
Sami Shalayel 481e6b8278 qmlls: fix slow lint suggestions
Qmlls is very slow when showing lint suggestions while writing code,
sometimes it does not even show lint suggestions (you need to enter some
characters until they appear, and lint suggestions disappear while
writing completely unrelated code.

Change the "waiting for new keystrokes when finding an invalid document"
delay from 4000ms to 400ms to display lint errors as soon as the users
stops typing.

Overall, the logic to choose the current version to show lint warnings
on is buggy and unreadable, so it was rewritten into the helper
methods "chooseVersionToDiagnoseHelper" and
"chooseVersionToDiagnoseHelper".

The old implementation of chooseVersionToDiagnose would sometimes pick
no version to be diagnosed for invalid documents, and then the code
would send a message to the client claiming "no errors found" (because
no diagnostic was executed). This is the cause for the lint suggestions
sometimes disappearing when writing unrelated code, and sometimes
shortly reappearing during certain keystrokes.

The new implementation checks for
* was current version already diagnosed? skip
* is current version valid? diagnose
* is current version invalid and recent ? wait for more keystrokes in
  case user is typing
* is current version invalid and older than 400ms? diagnose

Extract the two lambdas "addLength" and "messageToDiagnostic" into their
own static methods, and make sure no diagnostic results are published
when no diagnostics were executed.

Also, add tests that allow to simulate the user typing some code.

Pick-to: 6.5 6.6
Change-Id: I9c8300e7d1b4f9b10e576ece983d927535a7e4a8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-08 18:18:08 +02:00
Sami Shalayel e50e9639fe qmlls: highlight property names inside of property definitions
When searching for a definition or a usage of a property, qmlls was
reporting the entire property definition (property int i: 123) instead
of just the identifier. Return just the location of the identifier 'i'
instead and fix the tests that expects the old behavior.

Change-Id: I47cc3aba92ce15d9036dc1772bdd9ed4d537c884
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-08 15:12:46 +02:00
Edward Welbourne fc767c2441 Fix QML error, accessing global status
Give the outer QtObject an id so we can overtly access its status.

Change-Id: Iffe68b85cc43d2bedf046dc40d6c6cae34569072
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-08-08 15:12:46 +02:00
Ulf Hermann d07744ef5d QmlCompiler: Fix SetLookup on shadowable properties
If we are procedurally setting a shadowable property, the read register
for the value will be converted to var. We can therefore not just
retrieve the property type again in the code generator to determine what
we have to do.

What we actually need is the information on the original scope type of
the lookup. We need to know what exactly the base type was supposed to
be. To that effect, store the scope of the target for each conversion in
QQmlJSRegisterContent.

We need to circumvent the questionable optimization of "deduplicating"
functions that certain compilers exhibit, like we do for the getters.

Pick-to: 6.6
Fixes: QTBUG-115526
Change-Id: I361f2e46e39ece7892df72ae13ec756f9aec4adf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-08 15:12:46 +02:00
Marc Mutz 49e5532463 Port some trivial Q_FOREACH users to ranged for loops
The common theme amongst these is that this author detected in split
seconds that fixing the loop was easier than performing the #undef
QT_NO_FOREACH dance.

Naturally, all these fall into the category "loop over (readily made)
const local variables", which cannot possibly require the safety copy
that Q_FOREACH unconditionally performs.

Pick-to: 6.6 6.5
Task-number: QTBUG-115808
Change-Id: I652562711ae43e8bb36493ea990114d91c5b7d5d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-07 21:18:53 +02:00
Marc Mutz 6e497ca442 TestModel::Node: disable copy/move
The class owns a list of children via a QVector<Node*>, so copying a
Node would cause two Nodes to own the same children. So, go the extra
mile and use Q_DISABLE_COPY_MOVE(). Also shuts up Clazy.

Pick-to: 6.6
Change-Id: Ie225d4cd30e859f2a91cce36bc0a43be23b3b4e5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-07 21:18:46 +02:00
Marc Mutz 9427656fbc TestModel: port away from Q_FOREACH
Replace the foreach loop with a call to qDeleteAll().

This is required, in the grand scheme of things, because the code is
in a header, and that makes any TU including it (all, in case of PCH)
incompatible with QT_NO_FOREACH.

This is also safe, however, because a) Node is non-polymorphic and b)
the Node destructor (the function containing the loop!) doesn't
attempt to unregister from its parent, so we know exactly what code is
being run here, and it's not modifying the container.

Task-number: QTBUG-115808
Change-Id: I5e434d55945fa36b318427a4ea528ac4991422c8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-07 21:18:41 +02:00
Fabian Kosmale 9bc8445766 QQmlJSScope: purge qualifiedname
It is only used by a test (which doesn't test any other functionality
besides that we get the correct qualified name).
QQmlJSImporter::setQualifiedNamesOn keeps its current name, but probably
should be renamed.

Change-Id: Ie36c342943b545be0de7bba53a2fbd6c6f0adc0d
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-08-07 20:44:01 +02:00
Fabian Kosmale 5461b90cda QQmlJSScope: Decouple ContextualTypes
ContextualTypes are required in the import visitor logic, but they
aren't actually used directly inside QQmlJSScope.

Change-Id: I5cd49076687ef97c1077678c8dc757cde3b94c51
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
2023-08-07 20:43:44 +02:00
Sami Shalayel 03aaacbfce qmlls: preparation to check names during rename
This commit does not add any new functionality but refactors the code in
qmllsutils to be ready for the "check if names are valid during a
rename" feature of renaming usages in qmlls.

Encapsulate the result of resolveExpressionType into its own struct.
Like this, resolveExpressionType can return additional information like
the type of identifier (a signal, a signal handler, ...) that was
resolved. Adapt the code using resolveExpressionType to use the new struct.

Rename namingAlternativesOf to resolveNameInQmlScope, as it actually
does resolve a name to whatever it represents in a QML scope (a
property, a property changed handler, a signal, and so on).

Rename findMethodIn and findPropertyIn to methodFromReferrerScope and
propertyFromReferrerScope to differentiate between the method
"hasMethodOrSignal" that "finds a method/property inside one QML scope"
and "methodFromReferrerScope" that "finds a method/property one can
call/use from the given scope that may belong to another QML Object".

Move some code from resolveExpressionType into its own static method
resolveIdentifierExpressionType. Also remove some code duplication from
resolveExpressionType and dead code (e.g. the QQmlLSUtilsResolveOptions
is only required when working on identifier expressions for qualified
names and properties).

Change-Id: I313711015675c23b53bb426a7124b8f4b57f4545
Task-number: QTBUG-114788
Task-number: QTBUG-114951
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-07 14:54:53 +02:00
Sami Shalayel de6da96030 qmlls: add support for renaming symbols
Add a qmlls module for renaming symbols, and start implementing the
rename operation in qmllsutils.

ToDos for later commits:
* sanitize the new name obtained from the user and warn if invalid. Also
  warn if current symbol cannot be renamed (because it is defined
  in another module or in a cpp file for example).
* support renaming Qml Components (including changing the qml file name
  defining the component) (requires implementing finding usages of Qml
  Components first)

Task-number: QTBUG-114788
Fixes: QTBUG-114948
Change-Id: I045949bd3a83c32fcb50ffb718c5a63e1f002c0c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-08-07 14:54:48 +02:00
Olivier De Cannière 2cf9aeccdd Compiler: Separate function prolog block and add validation of blocks
The function prolog logic is now separated in its own basic block. The
first "real" block with user code starts at offset 0.

Having the function prolog as a hidden part of the first block caused
some inconsistencies in block generation and would create empty blocks.
This happened for example when a back edge of a loop would target offset
0 in code where a loop condition is the very first set of instructions
that are run. This is because the target block offset didn't exist due
to it being part of the hidden prolog block.

Validation for the basic blocks was also added. This checks for three
things at the moment:
1. That return and throw blocks don't have jump targets.
2. That the basic blocks graph is connected.
3. That jump targets are the first offset of a block.

Test tst_QmlCppCodegen::basicBlocksWithBackJump_infinite() is expected
to fail because it contains an infinite loop and the basic blocks that
are generated for it are inconsistent due to dead-code elimination
happening earlier in compilation.

Debug outputs for dumping basic blocks were also adapted to reflect
these changes.

Change-Id: I513f73856412d488d443c2b47a052b0023d45496
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-04 09:34:09 +02:00
Amanda Hamblin-Trué c0f3a9bfe1 tst_qqmldebugservice: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I0d61741aba4e7c7b6b20396549c8550c51e1afc3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-03 14:28:13 +02:00
Amanda Hamblin-Trué b536990552 tst_qqmlengine: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I9373211ff008436cea560ce66eab0f8f80f0c20f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-03 14:28:08 +02:00
Amanda Hamblin-Trué 4ef0fec519 tst_qqmlcontext: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I21861c9c0b61f656b6bc6d212ff31f30e4aaf690
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-03 14:27:56 +02:00
Santhosh Kumar 85633bb9fe Fix mouse event delivery issue for items within SwipeDelegate
Swipe items that are direct visual child of SwipeDelegate control can
consume mouse events. But, if its configured within non-visual item
(such as row or column layout), the mouse events are not being
propagated.

This patch set fixes this issue by identifying visual child that can
consume mouse events at the event position through
QQuickSwipeDelegatePrivate::getPressedItem() and propagate it
accordingly.

Fixes: QTBUG-104904
Pick-to: 6.6 6.5
Change-Id: Ie7458db26d0d5fe1dd767326bb84605d06ba2ae8
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-08-03 08:13:34 +00:00
Fabian Kosmale 80376c480b tst_qjsengine: Adjust to qtbase change
The _q_reregisterTimers private slot has been removed from Q_OBJECT in
b902b152af0bf144c9c9833502e1dcfae0166620, and consequently it will no
longer be picked up by engine.

Change-Id: I11f3636092dc66bffa0bc54c3f1dd8fcf36aa691
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-08-02 11:20:30 +02:00
Semih Yavuz 115916f217 qmlformat: fix formatting of object destructuring
The following issues are fixed:
- [1]Incorrect detection of the property name as a string literal and
thus writing out them with quotation marks
- [2] Duplication of property name when a scoped variable is used as
property key
- [3] Writing out additional brackets during deconstruction
- [4] Incorrect formatting when a default is assigned to a lhs variable
like [a = 24, b] = array
- [5] Automatic addition of "" characters into the object keys
- [6] Automatic addition of assignment operator, instead only add it
when there is a pending initializer

Also, add the colon token location which was missing in the pattern
property rules. Remove it from a couple of rules that was giving
incorrect result. We require the location information of the colon token
to be correct when formatting.
A few of tst_qmlformat and tst_reformatter tests are adapted to the
above mentioned changes [1], [2], [5].

[ChangeLog][qmlformat][Important Behavior Changes] qmlformat will no
longer add "" characters automatically in the object keys unless the
object key is actually a string literal. Also, using a scoped variable
as the property key will no longer result in the duplication of the
property name.

Pick-to: 6.6
Fixes: QTBUG-108275
Fixes: QTBUG-114839
Change-Id: I272d41d13df34ff5877f3efebe43c80255dd7c2b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 14:06:18 +02:00
Amanda Hamblin-Trué 50548cd9d7 tst_qpacketprotocol: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I341706c859d044240a2482c7d1a795dfbb5709cc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:49:35 +02:00
Amanda Hamblin-Trué e595a2a1e0 tst_qsequentialanimationgroupjob: Clean up memory management
Task-number: QTBUG-115222
Change-Id: Ic0f755ebee21aea115e7e1e78f9100a6cb15522c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:49:30 +02:00
Amanda Hamblin-Trué 6f86e69dd5 tst_qqmlenginedebugservice: Clean up memory management
Task-number: QTBUG-115222
Change-Id: Iafe788fdfeb15bf4885e5e4bb473a3c4df4d68cd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:49:22 +02:00
Amanda Hamblin-Trué 1c34d3e81a tst_qpacketprotocol: Clean up memory management
Task-number: QTBUG-115222
Change-Id: If1ebb1e8cdd9172eb9aabb934389b5d8411759f1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:49:14 +02:00
Amanda Hamblin-Trué 92c7745945 tst_qparallelanimationgroupjob: Clean up memory management
Task-number: QTBUG-115222
Change-Id: Ic15e3eff84d5f7c423c1f101fd490b12bde7f638
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:49:02 +02:00
Amanda Hamblin-Trué ce4460198e tst_qabstractanimationjob: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I4741fcb11e8c7d4ddfe0f40db1c7cda21f19c3c1
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:48:53 +02:00
Amanda Hamblin-Trué 1065fdd042 tst_qv4debugger: Clean up memory management
Task-number: QTBUG-115222
Change-Id: Id276b6be33b812d30d6bd27445ff25308d66020f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:48:41 +02:00
Amanda Hamblin-Trué 0529361a9e tst_qjsengine: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I3b2348fa0ddd2087a5f35126bb0a0b6df3f8f8f4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:47:10 +02:00
Amanda Hamblin-Trué 7e8dbc0fcf tst_qjsmanagedvalue: Clean up memory management
Task-number: QTBUG-115222
Change-Id: Ie67f954f7d593035e02f2f95daf19e06937a4bd8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:47:03 +02:00
Amanda Hamblin-Trué cd24a13aef tst_qjsvalue: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I5e68a4f1c9f62760223c20f79b6193637f5b68bc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:46:57 +02:00
Amanda Hamblin-Trué aba9359dec tst_qqmlapplicationengine: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I69311982306c3b5ba30a38f0f082e3c21cbe1468
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:46:51 +02:00
Amanda Hamblin-Trué 74a4b27894 tst_qjsvalueiterator: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I71789690a10c9b18306be59f8519dd138b36294e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:46:44 +02:00
Amanda Hamblin-Trué f3b881a0cc tst_qqmlcomponent: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I1472bc38f261ec357b7a3c2d36116b76fca07867
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:46:38 +02:00
Amanda Hamblin-Trué 057b143fd5 tst_qqmlconnections: Clean up memory management
Task-number: QTBUG-115222
Change-Id: Ibbd52fa1cdd19fb32cc463b5a28a22dc3fbd14aa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:46:30 +02:00
Amanda Hamblin-Trué 4270473147 tst_qqmlconsole: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I067154627be93091c11b064d35cced0d6a5d6cd0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:46:23 +02:00
Amanda Hamblin-Trué e61da05b15 tst_qqmlcpputils: Clean up memory management
Task-number: QTBUG-115222
Change-Id: Iffef7c7eaa8d4a9ef3f83080c666b517a925cfbb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-01 10:46:15 +02:00
Fabian Kosmale 55494cf22f tst_qmlls: Fix issue with standalone test build
If the test is build as its own project, add_dependency will not be able
to find the target we pass to add_dependencies.
So make the check conditional (and assume that anyone building the test
as its own project has build qmlls before).

Change-Id: I632073f8e0f5cc21374435ba97a2d0ad50c831dc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-07-31 17:51:52 +02:00
Mitch Curtis c6b401a31a Fix attached property propagation when accessed on QQuickPopupItem
As mentioned in the comments of QTBUG-68434, popups always inherit
their attributes from the parent window (unless they are explicitly
bound like in ComboBox). However, ComboBox was made an exception,
because the popup is an integral part of the control.

This means that although the following snippet shouldn't change the
background color of a Popup, it should do so for ComboBox's popup:

    Rectangle {
        Material.theme: Material.Dark

        ComboBox {
            model: 5
        }
    }

However, this didn't work.
Before 3ec6d04d97, material/ComboBox.qml
had the following binding in the popup's background Rectangle:

    color: control.popup.Material.dialogColor

That patch changed it in order to get deferred execution working:

    color: parent.Material.dialogColor

This causes the color to come from the window rather than the popup.
This would have almost been caught in test_comboBox, had we checked the
actual color when setting the theme.

To fix the bug without reverting to the previous QML and breaking
deferred execution, we modify findAttachedParent to return the popup's
attached object if the item passed to it is a QQuickPopupItem.

Doing this causes test_inheritance_popup to fail, so we fix that by
passing the attached object target (which can be a popup) to
findAttachedParent, rather than the item whose parent or window changed
(which is coincidentally what was already being done in initialize()).

The patch also adds categorised logging to help debug such issues in
the future. Conveniently, this will also help users who want to debug
their own QQuickAttachedPropertyPropagator subclasses, without them
needing to modify Qt itself.

Fixes: QTBUG-115322
Pick-to: 6.5 6.6
Change-Id: Idc0495023a058bcb033c4002fb6ad233bae9feae
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-31 21:13:45 +08:00
Fabian Kosmale 4188b7e2a8 Context properties: Warn if name is numeric
We shouldn't allow such keys, as they get confused with array indices.

Task-number: QTBUG-115319
Change-Id: Iff37611925ff6aa8463baf26d221fd66ad919f2a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-07-31 09:40:10 +02:00
Fabian Kosmale b2b90c7cf5 Context properties: Don't trigger an assert for numeric names
The logic in our IdentifierHash assumes that every entry is a
StringOrSymbol; however, IdentifierTable::asProperyKey will convert keys
that look like numbers to ArrayIndex instead.
This is noramlly what we want, and not an issue, except for
setContextPropery where the user can pass an arbitrary string that is
not necessarily a valid identifier. In an ideal world, we would just
disallow such identifiers, but for backward compatibility change the
code to handle this case (avoiding a Qt internal assert).
We only need to modify the QString overloads, as those are the only ones
that interact with unsanitized user input.
A later commit will modify setContextPropery to warn if the key is
numeric.

Fixes: QTBUG-115319
Pick-to: 6.6 6.5 6.2 5.15
Change-Id: Ifc4e4d2bc99321836e6976c4cbd0c5ff687b430c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-07-31 09:40:06 +02:00
Fabian Kosmale 366fee74fc QQmlPropertyBinding: Correctly link observers after undefined valued binding
Calling both setObservers and prependObservers doesn't make sense:
setObservers is for the case where we don't have a binding, but
obviously we do have one here.

Note that the test case still passes even without the fix - it will
however cause a memory leak which can be detected by ASAN. The leak is
fixed by this patch.

Fixes: QTBUG-115251
Pick-to: 6.6 6.5 6.2
Change-Id: I4b420e05f49acf764da6a05af522390005276f49
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2023-07-28 20:24:28 +02:00
Ulf Hermann fa6aedf7ac QmlCompiler: Allow calling methods on potentially undefined QObjects
We can use the same technique as for GetLookup there. Just check the
variant for validity to see if we can call it.

Change-Id: I1bcf4a5a84f47e0236762827488bc5d03e015efb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-28 16:42:45 +02:00
Edward Welbourne 933d379f92 QML builtins: pass QDate and QTime by value rather than const ref
They're simple integral types, for all the special semantics they're
wrapped in.

Change-Id: I80934f3feec94b82a8ccdf5f8320b04b18939348
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-28 10:29:11 +02:00
Shawn Rutledge 0f4eb2320c SwipeDelegate: use QEventPoint's pressed pos for drag distance
QQuickAbstractButtonPrivate::pressPoint may not be set correctly,
and we don't need it for this purpose anyway in Qt 6, since every
QEventPoint is supposed to remember its own press position.

Task-number: QTBUG-61783
Pick-to: 6.5 6.6
Change-Id: Idd82f3d79b1167a40f28669d15b5974c7d240a9c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2023-07-28 08:04:59 +02:00
David Edmundson 066a1fed1f Use pixel aligned value in Flickable ends check
When animating a flickable with pixelAlignment enabled, the vData and
hData move still contain raw floating values.

The viewport and content items will use the pixel aligned values. We
recheck updateBeginningEnd based on when the viewport changes to emit
the atBeginning/atEnd signals.

If the animations speeds are just right, we can have a frame where the
hData.move is not at the end, but the aligned version is. This will
perform the last check in a way that fails the test for being at the
end, and not update again.

This patch uses the same value for the position as the content, aligning
if needed.

Fixes: QTBUG-115081
Pick-to: 6.5 6.6
Change-Id: I58afbe8a79994507e891391cb8f2af7e22380a9b
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-07-27 17:27:21 +00:00
Ulf Hermann afe96c4d63 QML: Do convert objects with prototypes to QVariantMap
While we shouldn't convert to QVariantMap if only QVariant is requested,
we should convert if QVariantMap is explicitly requested. QVariant can
hold QJSValue which is a better fit for objects with properties.
QVariantMap cannot hold QJSValue. A best effort conversion is still
better than an empty map.

Amends commit 47678c682f.

Pick-to: 6.6 6.5
Fixes: QTBUG-115523
Change-Id: Iaa96809ee411dc0db95311c641c4e3f1f51a6026
Reviewed-by: Amanda Hamblin-Trué <amanda.hamblin-true@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-27 14:42:00 +02:00
Fabian Kosmale e9c87ad1b2 tst_qmlcppcodegen: Split enum test
That makes it more clear which ignoreMessage belongs to which part.

Change-Id: I4c2bcc16b80204c6bb55c18459b7e8b0b1b298be
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-07-27 09:36:50 +02:00
Ulf Hermann 81bab13560 QmlCompiler: Force QObject* for LoadElement on list properties
In the presence of incomplete type information we may otherwise conclude
that the value type is QJSValue and generate broken code.

Pick-to: 6.6 6.5 6.2
Change-Id: I533f704a422d0efe8b7b5bb0a170966e9f290b1f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-26 16:54:52 +00:00
Edward Welbourne 201db1a827 Tweak a test to produce clearer output on invalid Date
If the Date is a NaN, there's no point reporting on the rest of its
failure to match the expected value.

Add a missing semicolon as a drive-by.

Change-Id: I9613d590c5ad9463b4b1b0b76f8b3877dead659c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-07-26 14:06:36 +02:00
Ulf Hermann ffa15d0e21 QML: When marking a QObjectWrapper, also mark its const counterpart
Otherwise the const wrapper will be swept while the object should still
be alive (and vice versa).

Amends commit d3b3fef5a8.

Pick-to: 6.6 6.5
Fixes: QTBUG-114596
Change-Id: Ib4d8e9f805a229a471ca72f5ff357e3a4c9999a5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-26 10:18:11 +02:00
Ulf Hermann 747c860354 QmlCompiler: Correctly handle lookups in results of method calls
Method calls often return just QVariant because we cannot be sure that
the method hasn't been shadowed. In order to figure out the right lookup
we should look at the type the type propagator assumed as the base of
the lookup. If the type propagator was assuming a list-length lookup we
need to try and generate a list-length lookup. If the base turns out to
be a QVariant after shadow-checking, the code generation will cleanly
fail (and refrain from generating bad code).

Amends commit 46cc70e2aa.

Pick-to: 6.6
Fixes: QTBUG-115278
Change-Id: I24dcd06161eb1af44450fb663d68a16d89efd6ac
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-25 16:33:29 +02:00
Ulf Hermann f0b2fbcf47 QV4::ArrayData: Fix offset calculation for sort()
We cannot just sort the raw values. We have to take the offset into
account. If the array wraps around the end of the allocation, we have to
move it around to be contiguous.

Pick-to: 6.6 6.5 6.2 5.15
Fixes: QTBUG-58718
Change-Id: I1866b3f271d97352e250d687955af3fc54340334
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-07-25 14:33:15 +02:00
Ulf Hermann fb4cc245e0 QmlCompiler: Optimize storage for register variables
We don't need nested hashes there. A single hash is enough, and we also
don't need to key it by pointers. Keying it by internalName instead
makes the ordering deterministic. We also don't need to duplicate-track
the variable names when outputting the declarations anymore.

Verify that qmlcachegen's output is actually stable by compiling the
entire test data for tst_qmlcppcodegen twice, packaging the generated
code into the resource file system, and comparing it in a separate test.

Pick-to: 6.5 6.6
Fixes: QTBUG-115159
Change-Id: I659661e58a52ed9ff308c83d6c821cf016f2e94e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-24 21:26:57 +02:00
Sami Shalayel deaa1bf54d qmlls: find usages of propertyChanged signals/handlers
If onSignalHandler is a usage of the corresponding signal, then this
should also be true for property changed signals/handlers. For some
property p, also find onPChanged and pChanged usages (and vice-versa).

Add a heuristic to discern property changed handlers from signals from
property changed signals from etc, which will be also needed for the
renaming operation in qmlls.

Fixes: QTBUG-111414
Change-Id: Idc179a288ef2771c094efadacdeb2a5b5bb89336
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-07-21 17:22:02 +02:00
Sami Shalayel 718d411362 qmlls: find usages of signals and bindings
Implement support to find usages of signals defined in QML or CPP and to
find usages of bindings, for the "normal" cases.
"Advanced" cases, which is about using QML objects like Connection or
Binding, will be covered in a follow-up commit.

Finding usages of signals:
Set the semantic scope of a signal's owner inside the signal, to be able
to differentiate between same-name signals of different types during
find usages. This requires to move code from
QQmlDomAstCreator::{endV,v}isit(AST::UiSourceElement*) to
{endV,v}isit(AST::FunctionDeclaration*), such that
QQmlDomAstCreatorWithQQmlJSScope can set the semantic scope in the
signal's MethodInfo during endVisit(AST::FunctionDeclaration*) instead
of endVisit(AST::UiSourceElement*) where the MethodInfo is already not
available on the node stack anymore.
Also implement finding onSignalHandler for signals as part of the
usages, and finding signals when finding usages of the onSignalHandler.

Finding usages of bindings:
Add an "identifier" region to FileLocations of bindings and property
definitions to be able to find the exact location of the property name
inside the property binding/definition. Change the existing tests to
only expect the source location of the property name instead of the
entire property definition.

Add tests for finding usages of signals and bindings and make sure that
functions contain a qqmljsscope in tst_qmldomitem::callExpressions()
and that Qml Object id usages can be found.

Disable a warning about prototypes not being a QmlObject: it is fine if
the prototype is also a QmlComponent.

Task-number: QTBUG-111414
Change-Id: Id6fd04ee7c04293a259588165f13b5ae8c78e9dc
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-07-21 17:22:02 +02:00
Sami Shalayel 8d3e116068 QQmlSignalNames: Add implementation for signal name manipulations
Add a set of static helper methods in
src/qml/common/qqmlsignalnames{_p.h,.cpp} to do signal name
manipulations (from signal to signal handler name and back, from
property to property changed signal to property changed handler and
back).

Add tests in tst_qml_common for the helper methods.

ToDo in following commit: replace all implementations of signal name
manipulations out there with the helpers introduced in this commit.

Change-Id: I8e606375839d9eda673da121a60484c5d211f4a0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-21 17:22:02 +02:00
Aleix Pol 589d0ee473 Fix fetching data when reuseItems is true
QQmlDelegateModelPrivate::requestMoreIfNecessary() is called in various
situations, including at startup, which calls QAIM::fetchMore() on the
model if it supports that. But we need to do it in one more case:
when delegates are being reused from the cache, the model could provide
more rows even though we aren't instantiating new delegates.

Amends 1841a9e41d

Fixes: QTBUG-95107
Pick-to: 6.6 6.5 6.2
Change-Id: I5b7ff48345ab78977cb03cfcf58ed96a57c831bd
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-07-21 00:56:03 +02:00
Marc Mutz 15721065e8 tst_QV4UrlObject: fix -Wtrigraph
The token sequence ??= used to be a trigraph for # until C++17 removed
the concept. Clang warns about their use, though, so escape the two
trigraphs in the test suite by splitting them with a pair of "".

Amends 6cca731f3e.

Pick-to: 6.6 6.5
Change-Id: I455883c4ad92541941fc8fed62277c97c24170db
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-07-20 22:08:59 +02:00
Amanda Hamblin-Trué d496f8c79e qqmllanguage: Clean up memory management
Use std::unique_ptr instead of QScopedPointer as it looks cleaner while
still providing automatic memory management and ensures that memory is
properly deallocated when the pointer goes out of scope.

Task-number: QTBUG-115222
Change-Id: I9ca93c44fee21ab2847540ab1a32f88cc942d293
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2023-07-18 15:20:21 +02:00
Marc Mutz 7db33bef41 Normalize signal/slot signatures
This is the result of running util/normalize on the code base. The
following manual edits were needed:

- skipped the hits in IS_SIGNAL_CONNECTED, which is using function
  pointers under the hood

- restored the space before * in Q_SIGNAL void foo(QType *arg)

Pick-to: 6.6
Change-Id: I299b3747c1aa2f6b3bc5ae1794edeb6fadfd75c6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-07-12 19:05:05 +02:00
Ulf Hermann 63b622d590 QML: Unify treatment of wrappers when dealing with QObjectMethod
A method can belong to a QObjectWrapper, a QQmlValueTypeWrapper, or a
QQmlTypeWrapper. store only one wrapper pointer and allow for all
variants. Furthermore, keep a reference to the wrapper so that it
doesn't get garbage collected. We still need it to retrieve the
metaobject, even if we're calling the method on a different instance.

Pick-to: 6.2 6.5 6.6
Fixes: QTBUG-115115
Change-Id: I1759fb687918ff79829fef776e0a93d29373b30f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-12 11:26:59 +02:00
Amanda Hamblin-Trué 7e65bb98c5 Add testcase verifying unshift misbehaving
When calling sort after unshift, array entries unexpectedly become undefined.

Task-number: QTBUG-58718
Change-Id: Ie577e6d983f22e02ab4ade3d1f722e7c44c2a981
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-07-11 23:48:05 +02:00
Jan Arve Sæther f33146ed0a Fix pointer delivery to child items of items with clip:true
QQuickDeliveryAgentPrivate::pointerTargets() can visit a lot of items
and their handlers, before actual event delivery really starts. One optimization in place since 6adc36115f
is that if an item is clipped, and the point is outside its bounds,
we can be sure that it's also irrelevant to the item's children,
because the parts of any children that may be under that point
are clipped away and invisible. At the time that was written,
QQuickItem::contains() was only doing a simple bounding-rect check.
Since then, bf74a908cb added
containmentMask; and we should also keep in mind the precedence
of the PointerHandler.margin property (currently, TapHandler.margin
does not expand the sensitive area beyond a clipped Rectangle, or
beyond the containmentMask either). So it seems we now need to check
clipRect().contains() explicitly: a child item may be outside its
parent's containmentMask, and containmentMask does not affect clipping,
so one would expect to still be able to interact with the child.
The current definition of clipRect() is from
9b62f4c27a. It's virtual, but
documented as "the region intended to remain visible if clip is true".

Fixes: QTBUG-115179
Pick-to: 5.15 6.2 6.5 6.6
Change-Id: I6ae8f492b99725459cdff2a89ac8508da5167102
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-07-11 20:55:49 +02:00
Ulf Hermann 20f608651b QQuickListView: Do not re-parent existing contexts
If we're not creating a new context, we should not re-parent it.
Otherwise it gets deleted in unexpected moments.

Amends commit 471c909a68.

Pick-to: 6.5 6.6
Fixes: QTBUG-115106
Change-Id: Ib51d80dda07096587c64ac2262d115ea08855cd2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-07-11 14:12:02 +02:00
Fabian Kosmale 901a8bf768 Windows native style: Mark ScrollBar as non-customizable
Consequently, remove code that supported setting a non-native
contentItem.

Task-number: QTBUG-107771
Pick-to: 6.5 6.6
Change-Id: I871156c567f85db6e1b8247dcc6c2ea6a350cd4d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2023-07-11 12:19:59 +08:00
JiDe Zhang 4e7a83156d Add the reset function for properties of QQuickPalette
Allow reset the group colors of QQuickPalette, and ensure ResolveMask
value of QPalette is right.

Pick-to: 6.5 6.6
Fixes: QTBUG-104008
Change-Id: I57d71f6be73286b78bf0c31927993e39f9fab8d3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-07-10 16:56:10 +08:00
Ulf Hermann 8a073501ac QtQml: Do not crash on invalid import URLs
We get rather unusual file URLs if we let an import with an invalid URL
pass. Once those files are referenced, we hit some asserts.

Pick-to: 6.6 6.5 6.2
Change-Id: If7acefcd07c844e680be9db6e49b5ef366baea4b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-07 23:58:55 +02:00
Ulf Hermann 1c2ef41a88 QtQml: Respect import namespaces when importing scripts
Pick-to: 6.5 6.6
Fixes: QTBUG-113991
Change-Id: I47651f303bcb53dc214d5f6bc70f65bac32f1b09
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-07 23:58:55 +02:00
Ulf Hermann 8b1ee76623 QtQml: Fix validation when calling methods with different 'this'
We were checking the wrong method offsets and we didn't check for
destroy() and toString().

Amends commit 3fd3a2a9d0.

Pick-to: 6.5 6.6
Change-Id: I8ebeb927a7827cc1fd3394fb3ab589c35d31ab70
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-07 23:58:55 +02:00
Axel Spoerl e9f631b092 QQmlDelegateModelPrivate:object: release objects only with objectRef >0
If a cache item has an object and there are no pending incubation
tasks, it returns the object.
Otherwise, it releases the object, before deleting the cache item, if
it is unreferenced.

If the cache item's object has a zero objectRef, because it is still
under construction, the method attempts to release it.
Releasing an object with a zero objectRef triggers an assertion in
QQmlDelegateModelItem::releaseObject().

The cacheItem's object is referenced in qqmldelegatemodel.cpp:1234,
which increases the objectRef from 0 to 1. It is set to 0 again,
if the cacheItem has a delegate, which gets incubated in
qqmldelegatemodel.cpp:1281. This case is not reflected later, and the
cacheItem's object is unconditionally released.

This patch makes the release attempt conditional to a positive
objectRef. It adds an autotest in tst_QQmlDelegateModel.

Fixes: QTBUG-104469
Pick-to: 6.6 6.5
Change-Id: I5c0751ca7f796a9701889520c526f719a27a200b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2023-07-07 13:07:06 +02:00
Ulf Hermann ca27c051ab QmlCompiler: Allow creation of structured value types
With this change, qmlcachegen can populate structured value types from
object literals.

Also fix the construction of value types via Q_INVOKABLE ctors. We don't
need to wrap the ctor argument in QVariant if we can store the original
type, and we should always look at the base type for the creatable flag,
not the extension.

Task-number: QTBUG-107469
Task-number: QTBUG-112485
Change-Id: I9f3db13f00466dc9d87237bdf0b380d6eeb58a10
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-06 21:29:39 +02:00
Ulf Hermann 4ac6d0ffb0 QmlModels: Recognize more sequential iterables
We don't need a QQmlType in order to find an iterable. We can also try
to convert the QVariant right away. This way we can handle things like
QList<QJsonObject> that haven't been registered. Those were converted to
JavaScript objects and then to QVariantList before, a rather wasteful
procedure.

Amends commit b9bfdea0e2.

Change-Id: Ib3e33e317892ada04e1880c5cbadfcfd614e9398
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-06 11:26:17 +02:00
Mitch Curtis 345189c469 QQuickTableViewResizeHandler: don't accept events outside of us
Handlers can be sent events that are outside of the target
item, so check for that in wantsEventPoint.

Fixes: QTBUG-111013
Pick-to: 6.2 6.5 6.6
Change-Id: I52f17fc7030a93d999188fe7608411f11d235858
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-07-06 09:26:17 +00:00
Ulf Hermann 3110117bfa QML: Check result when constructing object from metaobject
If you pass insufficient arguments to call the ctor, the resulting
object is null and cannot be used.

Pick-to: 6.6 6.5 6.2
Fixes: QTBUG-114910
Change-Id: Ib184684b6a7665bcdc1a3fe8f8a2401a33a8ac1c
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-06 11:26:17 +02:00
Ulf Hermann b7b63ba92c QmlCompiler: Do not generate code that shadows arguments
Pick-to: 6.5 6.6
Fixes: QTBUG-114897
Change-Id: I23bc913a86ee90764735c1661cd5036f7d177a22
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-06 09:07:41 +02:00
Amanda Hamblin-Trué 514fa7e284 Remove redundant warning
We already have a generic warning for assigning null to properties
that don't support it, so we warn twice.
Removed redundant warning so that we only warn once.

This partially reverts commit 16aff415a4.

[ChangeLog][QtQml][Important Behavior Changes] Assigning null to
a property of incompatible type is now an error instead of a warning.

Fixes: QTBUG-102980
Change-Id: I739913ab64628376727b751512717eb4bf7ea5f4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-07-05 10:34:12 +00:00
Alexandru Croitor 1e5252f82e CMake: Make qtdeclarative tests standalone projects
Add the boilerplate standalone test prelude to each test, so that they
can be opened with an IDE without the qt-cmake-standalone-test script,
but directly with qt-cmake or cmake.

Boilerplate was added using the follow script:
https://git.qt.io/alcroito/cmake_refactor

Manual adjustments were made where the code was inserted in the wrong
location.

Task-number: QTBUG-93020
Change-Id: Ibd12efab09ceb5852395e40f10b55fafb69c1b58
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-07-05 12:34:12 +02:00