Commit Graph

9957 Commits

Author SHA1 Message Date
Fabian Kosmale bc62914fe3 QQmlSA: Turn BindingType into a enum class
This avoids future conflicts between different "Invalid" values.

Pick-to: 6.6
Change-Id: I42f3d6e5b6d1b46931999dc2c72177872a104be9
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-08-30 14:18:17 +02:00
Fabian Kosmale 50f714789d QmlCompiler: Make LoggerCategory private again
It is not needed by the QQmlSA API. Additionally, remove the comparison
operator for LoggerCategory and LoggerId, and replace its users by
getting the id from the category before comparing.

Pick-to: 6.6
Change-Id: I7747b09b941cfd5326b95d2ee2f78b0ee10991d3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2023-08-30 14:18:17 +02:00
Ulf Hermann 4cdf0643b4 QtQml: Key singletons by singleton instance info
We can keep the singleton instance info the same across multiple types
created in a single registration call. The result is that we only get
one singleton instance per engine, rather than separate ones for each
version. If you invoke qmlRegisterSingletonType separately, you still
get separate instances, though.

[ChangeLog][QtQml][Important Behavior Changes] The QML engine will now
refrain from creating separate instances of a singleton type for each
version it is registered for if the singleton is registered
declaratively (using QML_SINGLETON). The behavior of procedurally
registered singletons (using the qmlRegisterSingletonType() family of
functions) remains the same: For each registration call, a separate
singleton instance is created.

Task-number: QTBUG-116432
Change-Id: Ic8a5de0f88ef530670cfd81b192201a8ab49b2f7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-30 14:18:17 +02:00
Sami Shalayel 50a7560b78 qmlls: show fix suggestions and enable quick fixes
Display the fix suggestions from qmllint in qmlls instead of just
showing the warning.
For example,
'Unqualified access: xxx is accessible in this scope because you are
handling a signal at 18:10. Use a function instead.'
sounds so much more helpful than the previous 'Unqualified access'.

Add an ending '.' in QQmlJSFixSuggestion's messages where missing.

Enable quick-fixes in VS Code and QtC by labeling quickfixes as
quickfixes. Everything that is not labelled a quickfix might need a
special language client implementation to work.
Also, add a test for quickfixes: it seems someone broke the quick
fix functionality in qmlls by mistake by relabeling a quickfix to
'refactor.rewrite'.

Task-number: QTBUG-115213
Change-Id: I350e23901b97d16a60bb39fdb4ab566b0d7fbdfb
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-08-29 21:34:09 +02:00
Fabian Kosmale 84de53c6b0 qmltyperegistrar: fix minor versions
If QML_ADDED_IN_MINOR_VERSION or QML_REMOVED_IN_MINOR_VERSION is used,
the QTypeRevision of the type will lack a major version. When we later
try to read them, that results in a value of 255. Instead of writing
out that value, fetch the value from the module, just like the engine
does at runtime.

Do the same for QML_REMOVED_IN_MINOR_VERSION.

Change-Id: I03d4364e1b62dda171dcf5bd4c327b1a00f616f5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-28 13:47:42 +02:00
Alexandru Croitor ba3cc0a094 CMake: Reference all qml resources in static qml plugin constructor
Previously, when a static library was made into a qml module, we added
resources containing the qml files, qmldir, etc, into separate object
libraries rather than directly into the static library.

We did this to ensure that the linker doesn't discard these resources
if they are not explicitly initialized with Q_INIT_RESOURCE in user
code.

This proves to be a problem for projects that link directly to the
static libraries instead of using target names, because the object
libraries that contain the resources are never referenced in the
cmake project and thus not linked in.
This tends to happen in projects that ship their own static qml
modules without accompanying target information.

To improve the situation, move all the resources back into the
backing libraries, and reference the resources inside the static
qml plugin constructor.

This way a project that wishes to link to libraries directly can do
the following and expect a working project:
- link to the static backing library
- link to the static qml plugin
- add Q_IMPORT_QML_PLUGIN(PluginName) in their project code.

This will ensure all resources are kept and initialized.

To implement that, use the new macros introduced in QtCore's
qtsymbolmacros.h which generate code to ensure symbols are not
discarded.

It's based on the same idea we use to keep the type registration
function: a volatile reference to the symbol to keep.

Add a test that confirms all this works.

Fixes: QTBUG-110243
Change-Id: I00a127ef17bc852e360fb7a2dc58ee20522424cd
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-08-28 13:47:42 +02:00
Mitch Curtis 950cd5888e Fix child popup palette inheritance
Qt Quick Controls Popups are always top-level popups, even if declared
as a child of another popup. Therefore, e.g. a font set on a parent
popup should not propagate to a child popup. The same behavior applies
to palettes, but we regressed with this in
1875ad7f92 and/or
31f5c21ddb.

This patch fixes the regression by returning the window's palette in
QQuickPaletteProviderPrivateBase<I, Impl>::parentPalette() if I is
a QQuickPopup.

Fixes: QTBUG-115707
Pick-to: 6.5 6.6
Change-Id: Ib89852787dd45e3edc9e846b6c182340c052f0fd
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-08-28 15:57:06 +08:00
Sami Shalayel d0fcb75aab qmlls: use resource files, when available
When linting via qmllint, the resource files are used to map from source
folders to buildfolders and are needed to load qmldir files from the
build folder, for example.

The linting module of qmlls was not loading qmldir, for example, because
it did not pass the resource folders to the linting method.
This is the reason why qmldir imports, for example, were not working in
qmlls.

Find the resource .qrc files from the build folder and let qmlls pass
them to the linting methods. Also fix the import folders to discover
in-source-directory qmldir files, when no qmldir file was found in the
build folder, in the same way as qmllint does it.

Add some tests for both cases (qmldir in build directory and qmldir in
the source directory).

Fixes: QTBUG-111429
Change-Id: I885c962cac5b1276f12bc28d6d47c43212f853e4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-28 09:57:05 +02:00
Sami Shalayel f95f070e5a tst_qmlls_modules: reset qmlls state between test runs
Previously, one qmlls instance was started and used for all the tests in
tst_qmlls_modules. This makes writing test really hard: if test X adds a
diagnostics handler to test qmllint messages from qmlls, then all the
following test will use this handler. If another test also wants to test
qmllint messages, it cannot add a second diagnostics handler. It also
cannot remove the first diagnostics handler (the Qt Language Server base
layer does not provide/allow 'unregistering' calls).

In any case, this is not beautiful. Instead, move the code that runs
a qmlls instance from initTestCase() to init() so that it will run
before each test and add a corresponding cleanup() method to close
opened files and qmlls.

Add helper openFile() and openFileFromAbsolutePath() methods to only
open the files needed by the test (instead of opening all the files for
all the tests). Also, this fixes the annoying "I wrote a test with its
own .qml file but forgot to open the .qml file in the test
constructor"-workflow, as each test requires to "openFile()" locally
instead of globally.
Add helper ignoreDiagnostics() to ignore qmllint messages when testing
something unrelated to qmllint messages.

Changed all uses of Uris to filePaths and add openFile(),
openFileFromAbsolutePath() and ignoreDiagnostics() to all the tests.

Excluded some qml files that crash the QQmlDomAstCreator (see
QTBUG-116392) in the formatting test.

Do not display errors from qmlls in the tests if enable_debug_output is
false to avoid spamming the output.

Task-number: QTBUG-116392
Change-Id: Ic7d2b07d4cb97b54673eb24d2f821dac77bf4e8b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-28 09:57:05 +02:00
Mitch Curtis 0d3a137254 Dialogs: fix statically-built applications not running
When attemping to run a statically-built Qt Quick app that uses
QtQuick.Dialogs, users would get an error:

    qrc:/qt-project.org/imports/QtQuick/Dialogs/quickimpl/qml/MessageDialog.qml:
    module "QtQuick.Dialogs.quickimpl" plugin "qtquickdialogs2quickimplplugin"
    not found

This patch fixes these errors by listing QtQuick.Dialogs.quickimpl as a
dependency through the qt_internal_add_qml_module command.

This does introduce an unconditional tooling (e.g. qmlimportscanner)
dependency on the non-native Qt Quick fallback plugin for all users,
regardless of whether they are using a statically-built Qt or not.
However, this should be fine, and the decision of whether or not to use
the fallback is made at runtime anyway, so it may not be possible to
conditionally add the dependency at CMake configure time.

Fixes: QTBUG-105745
Pick-to: 6.2 6.5 6.6
Change-Id: If2e4c4346963e645bd8e5e9cc210c7b38c8616c0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-08-28 13:03:26 +08:00
Ulf Hermann 3ca5a7b3b6 QmlCompiler: Clean up equality operators
The special cases added for the number and null operations are generally
useful also for other kinds of equalities and vice versa. Furthermore,
there is no point in std::move'ing registers into equality operators.

Task-number: QTBUG-115110
Change-Id: I6de634ee45e13aefd069677c4bf75020875e09fa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-25 23:58:12 +02:00
Ulf Hermann f839171eef QmlCompiler: Allow creation of actual QVariantMaps from object literals
There are places where we need this:

a, If the method in question actually takes a QVariantMap as argument.
b, If the resulting value can be shadowed. In that case we expect a
   QVariant. The engine has to internally convert to the expected type
   then.

Change-Id: Ic5b3faab4578d64ca757de644fe69660fd70e52a
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-08-25 20:36:46 +02:00
Ulf Hermann 555125416e QmlCompiler: Allow coercing date values to numbers
This is the equivalent of JavaScript's valueOf().

Change-Id: If850519d6dbc7354b447acb6aad8ac04211d059d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2023-08-25 20:36:37 +02:00
Ulf Hermann ede3389a3e QmlCompiler: Allow setting values in sequences
Since we have write-back available now, this is not difficult anymore.
This does not yet cover setting properties of value type objects stored
in sequences such as "a[i].b = c". You can only set the whole element.

Task-number: QTBUG-116011
Change-Id: Id5f7a19125897602880e573d5f25b025f9b91f34
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-25 20:36:33 +02:00
Ulf Hermann 72e9f47526 QmlCompiler: Allow write-back to members of objects
This covers recursive write-back, but not write-back to members of
singletons or attached types, write-back of lists.

Task-number: QTBUG-116011
Change-Id: I6d33fae3bf9fdaed8d696a708124e0a707ecb07e
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-24 12:39:43 +02:00
Ulf Hermann bd9a8eb6df QmlCompiler: Store lookupIndex in register content for properties
This way we can generate a separate register variable for the result of
each lookup, which guarantees that we can write back to it if necessary.

Task-number: QTBUG-116011
Change-Id: I1d2b8948d8edb66f0665399768df194065dc99be
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-24 12:39:35 +02:00
Ulf Hermann 353bb06ed7 QML: Load the implicit import before resolving scripts
Scripts listed in the qmldir of the implicit import have to be made
available as references in the context.

Since we now also load singletons from the implicit import and check
them for errors, the test that deals with errors in singletons in the
implicit import has to be adapted.

Change-Id: Id324b2d9f646d9f48cf46e1c9dd89a0701fcea7e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-24 12:39:17 +02:00
Ulf Hermann 8d9dfd3347 QmlCompiler: Fix conversion from/to void
We can convert everything to void, but we can only convert from void if
the result is either void or the invalid type.

Pick-to: 6.6
Fixes: QTBUG-116088
Change-Id: I532055405865c5b1581f79cc5d76c253bce6138d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-23 15:30:11 +02:00
Ulf Hermann 7cb7f6ab7f Remove remaining foreach in quick tests
Task-number: QTBUG-115808
Change-Id: I30c27cf9972257897f15d57d62ff05ad1028b35e
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-23 15:30:11 +02:00
Sami Shalayel cc46882322 cmake: add option to generate .qmlls.ini files
Add a CMake bool variable QT_QML_GENERATE_QMLLS_INI to indicate
to qt_add_qml_module that .qmlls.ini files have to be generated for
each directory where qt_add_qml_module is invoked. The .qmlls.ini
files are generated in the source directory.
This option needs to be set explicitly by the user, either as normal
or as cache variable.

The .qmlls.ini files are required for qmlls to work properly in any
editor, without needing custom qmlls-client implementations for every
client that passes the build folder on to qmlls.

Each source directory with a CMakeLists.txt that does the
qt_add_qml_module command gets a .qmlls.ini that contains all the build
folders of all qt_add_qml_module-commands of the current source
directory. This mimics how qmlls searches for the .qmlls.ini (starting
at the source file directory and going up until it finds a .qmlls.ini),
and avoids having to save a map from source folders to build folders in
the .ini file.

Warn the user when using CMake versions <= 3.19:
QT_QML_GENERATE_QMLLS_INI requires deferring the calls to write the
.qmlls.ini files to make sure that all build paths of all
qt_add_qml_module calls of the current directory can be written
inside the .qmlls.ini file.

For multi-config build, this just makes use of the last generated
config and overwrites the .qmlls.ini files for the other files.
This is similar to what CMake does for compile_commands.json on
the ninja multi-config generator, see
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7477 for
example.

Added some documentation about the option, and also a test.

Fixes: QTBUG-115225
Task-number: QTCREATORBUG-29419
Task-number: QTCREATORBUG-29407
Change-Id: I4a463ff7af534de266359176188fb016d48cf2c4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-23 12:31:08 +02:00
Ulf Hermann d3c0515951 Remove remaining foreach in qml tests
Task-number: QTBUG-115808
Change-Id: If02f3cbb97e8a6035544d10ee2c23f5c87ed618c
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-22 20:11:34 +02:00
Ulf Hermann 1d3385e988 QtQml: Reset context object when destroying it from QObjectWrapper
There may be other objects that still hold on to the context data. We
should not leave them with a dangling context obejct.

Pick-to: 6.6 6.5 6.2
Fixes: QTBUG-116228
Change-Id: I3dddd20b13956408d0e66c3a46e59377e45d91e5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-22 20:11:34 +02:00
Ulf Hermann 2eac7350c0 QmlCompiler: Stabilize test
Loading the implicit import might add extra types that use up indices.
So, make sure the implicit import has already been loaded at that point.

Use a file that only has one type reference so that the ordering of type
references cannot mess up the selection of indices for types.

Change-Id: Ia33979e660e114ef608e1f5e22252c822c7f3d61
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-22 20:11:34 +02:00
Ulf Hermann d908d5e57c QmlCompiler: Allow construction of Array objects
Currently, only the constructor form of the Array function is compiled.
We only compile construction of Array objects if we can determine that
they are immediately assigned to a typed list. Consequently, we don't
have to deal with sparse arrays.

Change-Id: I2abd15139eb9a0d530ad49df7313b8dba415ae77
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-22 17:16:53 +02:00
Fabian Kosmale 603fb28d1d QQmlBind: handle top-level attached properties
While top-level attached properties are formally deferred in QQmlBind,
QQmlBind is not really interested in them. Top-level attached properties
cannot be generalized grouped properties, after all. Therefore, populate
the attached objects the usual way when encountering them.

Pick-to: 6.6 6.5
Fixes: QTBUG-116049
Change-Id: I18e8759ea52fd91fadf80b2cc69b5054f7cea23a
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
2023-08-22 09:12:56 +02:00
Kai Uwe Broulik 139d45c062 QV4::QObjectWrapper: Use the object's actual meta type
Otherwise, a derived type's methods will not be found.

In our particular case we tried to call a method of 'B*' on a
QML attached property declared as 'A*'.

This restores the previous behavior of using the object()
for the meta type except for when it's a value type wrapper.

Amends commit 63b622d590.

Pick-to: 6.6 6.5 6.2
Change-Id: I08b9f4b97a58c15fdc3703dd3c5d927cd1beb3ce
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-08-22 09:12:56 +02:00
Ulf Hermann ec25258346 QtQml: Create implicit components in inline components early
When the resolve() method is called on an inline component root we can
resolve implicit components inside that element right away. If we wait
for the inline component root to show up again in an outer element,
there are a number of code paths that may miss it.

Pick-to: 6.6
Fixes: QTBUG-98859
Change-Id: I5a37422332fc2cde6b9b2f7ca9ad73ac3bbd4ff2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-22 05:05:50 +00:00
Kai Uwe Broulik 8c852c70c9 QQmlDMAbstractItemModelData: Guard against deletion during model write
When a `setData` call on a model results in our row being removed
(e.g. when a proxy model filters out the row as a result of this
change), an Instantiator would delete us and we'd try to emit a
property change on garbage `this`.

Amends commit 5db77fb406bb36a27de1ad2e3390720411c833f9which made
Instantiator clean up its objects on a model change.

Pick-to: 6.6 6.5
Change-Id: I5570453de588e32dc5e4235287a83565e5185aa2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-08-21 20:52:01 +02:00
Ulf Hermann 487bd23ee8 QtQml: Correctly resolve aliases to aliases when loading .qmlc files
We need to loop the objects until all property caches are resolved. We
cannot assume the property caches to be complete right away.

Amends commit 2d7fe23b41.

Pick-to: 6.6 6.5
Fixes: QTBUG-116148
Change-Id: I407675cd1ebf8067d1b387542b4ecca8100d9b34
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-21 18:26:17 +02:00
Edward Welbourne 526a6da895 Revert "Skip the date time conversion tests on Windows"
This reverts commit 347496843d, which
added #ifery to skip some tests without documenting what the alleged
problem with QDateTime was. However, it seems the problem has been
fixed since 2013.

Change-Id: Ib29d97920aa43f399f05ed901add2328b18d2669
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-21 12:10:04 +00:00
Dennis Oberst 4f9687927d CMake: Add the Svg package to OPTIONAL_COMPONENTS
It is an optional dependency of the module and some examples and tests
depend on it.

Since this patch enables the Svg package on the CI, a previously
unexecuted test has begun failing on the Android platform. This seems to
be a known issue, thus add this particular test case to the BLACKLIST
file.

Change-Id: I46e00308a81189c80c7d788920908a884d05663d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-08-21 14:10:04 +02:00
Amanda Hamblin-Trué 508b41474a tst_qrcqml: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I914ce468b20d8f419d41eadc4b987a2810444886
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-21 08:46:36 +02:00
Amanda Hamblin-Trué b5c4cffe85 tst_qtqmlmodules: Clean up memory management
Task-number: QTBUG-115222
Change-Id: Iad8c747be4b0e999f432ae8fd952e30f5e324da9
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-21 08:46:31 +02:00
Amanda Hamblin-Trué 69498f605a tst_qquickworkerscript: Clean up memory management
Task-number: QTUG-115222
Change-Id: I548beabf2f4f969b874da27e67c9c9b1a09389f9
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-21 08:46:26 +02:00
Amanda Hamblin-Trué 23207a7150 tst_qqmlvaluetypes: Clean up memory management
Task-number: QTBUG-115222
Change-Id: Id63f096ee93f17fccf9c6796de74dfe99bbf2759
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2023-08-21 08:46:20 +02:00
Amanda Hamblin-Trué b131d33b2b tst_qqmltypeloader: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I8887ce3f4fcd69656725814cfb5d6dd00e4017e2
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-21 08:46:16 +02:00
Amanda Hamblin-Trué d075880a6a tst_qqmltranslation: CLean up memory management
Task-number: QTBUG-115222
Change-Id: I04fae4363411c905b2d76d4d2175480365a8e83d
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-21 08:46:10 +02:00
Amanda Hamblin-Trué 54a0ed9c7d tst_qqmltimer: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I4f627a18d2a961e47f36a37a7155d4f387cddda0
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-21 08:46:05 +02:00
Amanda Hamblin-Trué ea5ffb7b41 tst_qqmlpropertymap: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I23c43432b6b9e02ded694029a0290da038ece680
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-21 08:46:00 +02:00
Amanda Hamblin-Trué 6925562c35 tst_qqmllistmodel: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I1fba5bcdaabd87503cb2b4870881c50808bf4f99
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-21 08:45:55 +02:00
Amanda Hamblin-Trué 690cff76d4 tst_qqmlimport: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I82186e3690e0e4805f4abe2be626186bcf40100d
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-21 08:45:47 +02:00
Amanda Hamblin-Trué 1fedad3f11 tst_qqmlfileselector: Clean up memory management
Task-number: QTBUG-115222
Change-Id: I7ced805bf6dda39dc29aa8ed89d79786916d0dda
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-21 08:45:40 +02:00
Matthias Rauter ca20f7e82f Add a radius property for each corner of a Rectangle
This patch adds 4 properties to the Rectangle: topLeftRadius,
topRightRadius, bottomLeftRadius and bottomRightRadius. These properties
can be used to get a Rectangle where the corners have different radii.
If the properties are not set or if they are zero, the value of the
property radius will be used to draw the corner. If radius is zero too,
the corner will be drawn normally.

The opportunity was used to rename some variables in the
QSGRectangleNode and comment the code. We now use float as the storage
type for small-valued numbers, to reduce memory usage, even though the
setters take qreal values. They lose precision during rendering anyway.

[ChangeLog][QtQuick][Rectangle] Rectangle can now render individual
radii on each corner.

Fixes: QTBUG-48774
Change-Id: Icba1f6a26da513c657b7b218adc9187afb085eda
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-08-19 09:16:45 +02:00
Ulf Hermann 0f23346d2a QmlCompiler: Allow construction of Date objects
We map Date to QDateTime and special-case its constructors.

Task-number: QTBUG-111624
Change-Id: I0496f853613da3ccee9b6f6c4cf0adffa064f9f8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-18 14:26:04 +02:00
Matthias Rauter 37655a6e95 Make tst_QQmlEngineDebugService more reliable
Relying on the class name in the debugger can lead to problems.
Using the id should be more reliable.

Change-Id: Ic18a1535d8156d1af2fc66281491035014ac2fe0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-08-18 10:32:11 +02:00
Marc Mutz 8edbcdbeb4 Mark the module as free of Q_FOREACH, except where it isn't
The density of Q_FOREACH uses is high here, too high for this author,
unfamiliar with this code, to tackle in a short amount of time. But
they're concentrated in just a few TUs, so pick a different strategy:

Mark the whole module with QT_NO_FOREACH, to prevent new uses from
creeping in, and whitelist the affected TUs by #undef'ing
QT_NO_FOREACH locally, at the top of each file. For TUs that are part
of a larger executable, this requires these files to be compiled
separately, so add them to NO_PCH_SOURCES (which implies
NO_UNITY_BUILD_SOURCES, too). Created QTBUG-115808 to keep track of
this.

Task-number: QTBUG-115808
Change-Id: I29c377f939e3d747e3ce72c224c4ee722df7a95d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-17 18:04:35 +02:00
Sami Shalayel 055859f93f qmlls: highlight names inside of inline component definitions
Instead of highlighting the base type of the inline component, highlight
the name of the inline component, e.g. highlight 'C' in
```
component C: Item {}
```
instead of 'Item'.

This requires changing QQmlLSUtils::findTypeDefinitionOf's signature to
return a QQmlLSUtilsLocation instead of a DomItem.
QQmlLSUtils::findDefinitionOf already returns a QQmlLSUtilsLocation.

Also, the QQmlJS::UiInlineComponent parser class did not know about its
identifier token. Add it, so the corresponding DomItem knows where its
identifier lies.

Fix the tests that finds definitions of inline components by removing
the QEXPECT_FAIL and adjusting the column numbers. Also simplify the test
by removing the "name" that is not related to the actual test.

Fix other failing tests by setting their QEXPECT_FAIL at the right
place (they fail earlier because of this change, when looking for the
type definition of int for example).

Change-Id: I00b2f73c2357b7e7fb74619bbc7b948e67619420
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-17 13:55:33 +02:00
Semih Yavuz b6c89c0d13 qmlls: Add support for range formatting
Implement a selection based code formatter. A range
formatter is a code formatting tool that formats only a selected portion
of the code rather than the entire file. We now don't check the validity
of dom document, instead we read the source code and obtain the token
status of the previous line of the selected range. Then, indenting line
writer perfoms the indentation based on the last status.

For now, it has a limited functionality that it can only perfom
reindentation and whitespace handling. We will improve that with
QTBUG-116139

Exclude newly added test files from qmlformat test cases since currently
qmldom cannot handle unicode characters in code.

Fixes: QTBUG-112978
Change-Id: Iabf392a7b2623cfee44d042e1c87b021ccc6e5e6
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-17 10:19:48 +02:00
Semih Yavuz 4f335c11f7 qmlls: find usages of signals in Connections objects
The signal handlers within the Connections object work as signal
handlers for the designated target of the Connections object. Thus, we
should enable find-usages for them as well, ensuring that they are
identified as instances of the signals they handle.

Task-number: QTBUG-114901
Change-Id: Ic776d15358964da07590543fbf7d949a25f5630a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-08-17 00:43:46 +02:00
Ulf Hermann f6735dba95 QmlCompiler: Fix console logging
Store a copy of the UTF-8 data for file and function so that we don't
run into heap-use-after-free.

Set the instruction pointer before calling the log function so that we
get a correct line number.

Pick-to: 6.6 6.5
Fixes: QTBUG-114655
Change-Id: I38249fe52719ddad620033716ff22b2087ab8382
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-15 17:48:43 +02:00