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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>