Commit Graph

124 Commits

Author SHA1 Message Date
Alexandru Croitor a8431a4067 CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers
Change-Id: I1cd769f85d5f82c43639d6787d98e536619249e6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-28 14:58:42 +02:00
Lucie Gérard 5a7b716474 Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I72c89a98c42bbc9234d8495e9e503bec81d11037
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-08 10:41:06 +02:00
Lucie Gérard 0dc4fd240a Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-06-11 08:05:15 +02:00
Ulf Hermann d0c7c7234c Generalize role selection mechanism from QQuickComboBox
We can have QQmlDelegateModel pick specific roles from model items. That
can easily be done for variant maps, variant hashes, objects and
gadgets. We would like to do it for anything that has a
QMetaAssociation, but as we cannot get to the original type at that
place, it's currently not possible.

The special case about variant maps with exactly one item in variant
lists is clearly insane and therefore not included in the
generalization.

This requires some cleanup in the QQmlGadgetPointerWrapper. Passing the
wrapper itself to QMetaProperty::read() has always been a rather obscure
way of reading from the gadget.

Pick-to: 6.3
Fixes: QTBUG-102983
Change-Id: I84ecef980783e7137aa4d77070ddce47b6ead260
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-11 16:25:16 +02:00
Sona Kurazyan 2c9c1590e6 Replace uses of deprecated _qs with _s/QStringLiteral
Task-number: QTBUG-101408
Change-Id: Ic925751b73f52d8fa5add5cacc52d6dd6ea2dc27
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-29 09:47:43 +02:00
Andreas Buhr 93193747e8 Repair tst_qqmlproperty on Android
tst_qqmlproperty tries to start itself in another environment
using QProcess. This does not work on Android.

Task-number: QTBUG-101865
Pick-to: 6.2 6.3
Change-Id: I8e0410cf315e53899a88cf1b3c9dfba605b7f4d9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-05 13:57:56 +02:00
Volker Hilsheimer aee6b231d0 Fix warnings in tests after QQmlListReference change
The engine parameter is no longer used.

Pick-to: 6.3
Change-Id: Ifc630eb4803a015d41df50210bd86947f6a5a472
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-03-21 12:45:58 +01:00
Ulf Hermann 44ca135c5a QQmlProperty: Prohibit ID lookup on explicitly given object
If an object is given, we should only use that object.
Amends commit 21f15ede60.

Pick-to: 6.3
Task-number: QTBUG-100110
Change-Id: I51c0a44750c31984ba4937fb1cd2405dd93fcc19
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-21 16:22:28 +01:00
Volker Hilsheimer d62c216cbd Don't crash when accessing QVariant data pointer
The write method is called with a QVariant, and even though the property
might be of a QObject type, the variant might not contain a QObject. So
accessing the variant data directly via QVariant::constData and
static_cast'ing the void* to QObject* is not safe.

Add an explicit check before accessing. An alternative would be to at
least Q_ASSERT that the result of the cast and a QVariant::value call is
the same, which would then not introduce any performance penalty in
release builds. However, users use release-builds of qml and Qt tooling
to write QML, and we writing wrong QML code should not crash then
either.

Include a test case that segfaults without the fix.

Pick-to: 6.2
Fixes: QTBUG-98367
Change-Id: Ib3ae82d03c9b2df6251ee88d5bd969dd4f796a41
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-11 06:13:37 +01:00
Ulf Hermann d1409760ec Do not crash on self-assignment of QQmlProperty
If you had a QQmlPropertyPrivate with only one reference, assigning its
QQmlProperty to itself would delete the QQmlPropertyPrivate.

Pick-to: 5.15 6.2
Change-Id: I73f8e6df63af09d3f43a101749a5800153499057
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-10 11:22:15 +01:00
Volker Hilsheimer 30728c1107 Fix compiler warning
tst_qqmlproperty.cpp:2426:55: warning: loop variable 'flagSet' of type
'const QQmlPropertyPrivate::InitFlags' (aka 'const QFlags<QQmlPropertyPrivate::InitFlag>')
creates a copy from type 'const QQmlPropertyPrivate::InitFlags' [-Wrange-loop-analysis]

Use idomatic "const auto &" in ranged for loop.

Change-Id: I9efcf5dad6204ddd6ddbc117f87d3b1f7c943fc1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-09 11:46:52 +01:00
Ulf Hermann 21f15ede60 QQmlProperty: Add flexibility to initProperty()
Using private API, you can now construct a QQmlProperty from an unknown
object by passing a dot-separated string that starts with an ID. You can
also have a plain signal name (without "on") as the last part of the
name. Both variants are optional and have to be enabled via flags.

In Qt7, we should clean up the "on" vs. plain signal name affair. For
now we can't because everything expects the "on".

Constructing properties from ID'd objects can only be done in specific
places. Therefore this has to be manually enabled.

Furthermore, you can now create properties, not only signals, from plain
QMetaObjects. This is enabled unconditionally because there was no
reason for this to not work before.

Change-Id: I9ff764130b70f9d023ab63d492f83290e8e87ef3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-10-27 08:40:21 +02:00
Ulf Hermann f2a15482dd Add a Pragma for list assign behavior
[ChangeLog][QtQml] You can now specify the list property assignment
behavior in QML using the "ListPropertyAssignBehavior" pragma. This is
analogous to the macros you can use in C++.

Fixes: QTBUG-93642
Change-Id: I9bdcf198031f1e24891f947b0990a3253d29a998
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-10-13 14:03:41 +02:00
Fabian Kosmale e82a6bdad3 QML engine: Resolve URLs on property assignment when given an env var
This is a partial (and manual) revert of
0a1e4cc7ec. We still do not intercept
during property assignment, but relative URLs get resolved in the
current context if QML_COMPAT_RESOLVE_URLS_ON_ASSIGNMENT is set.

Pick-to: 6.2
Task-number: QTBUG-95587
Change-Id: Ib2955541d2626fd26d3886b33f8ba0c2f940779b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-10-06 06:39:34 +00:00
Mitch Curtis e310dadef7 Consolidate test helpers into private libraries
Previously each test would include and build sources from the shared
folder. Now we make those sources a library, build it once, then have
each test link to it instead.

We also take the opportunity to move some helpers that qtquickcontrols2
had added into the quicktestutils library where it makes sense, and
for the helpers that don't make sense to be there, move them into
quickcontrolstestutils.

We add the libraries to src/ so that they are internal modules built as
part of Qt, rather than tests. That way we can use them in a standalone
test outside of qtdeclarative.

Task-number: QTBUG-95621
Pick-to: 6.2
Change-Id: I0a2ab3976fdbff2e4414df7bdc0808f16453b80a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-09-13 21:17:04 +02:00
Craig Scott c1273bf1d0 Make qt6_qml_type_registration() internal
This renames the command to _qt_internal_qml_type_registration().
The tests are only updated to use the new name so as to keep this to a
minimal change.

Fixes: QTBUG-95093
Pick-to: 6.2
Change-Id: Ie3a7f6adc312050df64213fdcdc62886ad21ff01
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-08-25 17:59:39 +10:00
Fabian Kosmale 45db3fae3a QQmlProperty: Implement DontRemoveBinding support for QProperty
The animation system currently relies on being able to write to
properties through the meatobject system without breaking their
bindings. This patch ensures that the DontRemoveBinding flag is honoured
for QProperty based bindings, too.
It is implemented by setting the private stick flag on the binding
before doing the write and then removing it again after the write is
done. This roundabout approach is necessary as the BindableInterface
does not expose the setValueBypassingBindings functionality, and simply
writing to the propertyDataPtr would prove disastrous in the case of
QObjectCompatProperty.

Fixes: QTBUG-91689
Change-Id: Ife1afb9c94190f1c4e9658a7193aba6dbdaa281f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-05-12 14:07:36 +02:00
Andreas Buhr 7e029878c0 Fix some "can be marked override" warnings
Change-Id: I13da0d085901314950c4fa0afb5853e183652e67
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-02-23 16:50:07 +01:00
Fabian Kosmale 1ff376e64b QQmlPropertyPrivate::signalExpression: handle object being null
QQmlData::get expects a non-null pointer, therefore we need to check
whether the object still exists.

Note that while this fixes the crash in the referenced bug,
PropertyChanges still does not support a dynamic target.

Pick-to: 5.12 5.15 6.0 6.1
Task-number: QTBUG-46350
Change-Id: Ifeecf5df83e87468a1d314ce2b120006124d6f4b
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-19 08:03:13 +01:00
Fabian Kosmale 78ab4b8d8b Remove the qmake project files
Remove all qmake project files, except for examples which are used to
test that qmake continues to work.

Change-Id: Ic4abb72dc2dcd75df7a797c56056b6b3c5fe62ac
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-01-15 15:34:22 +01:00
Maximilian Goldstein 8753390073 qqml.h: Add QML_IMPLEMENTS_INTERFACES
Needed in order to allow for the declarative registration of classes implementing
interfaces.

Fixes: QTBUG-88623
Pick-to: 6.0
Change-Id: Id9c1ae92774dd9c316ceaa737cb48ef28f56545c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-23 08:39:03 +01:00
Maximilian Goldstein 7f74a613f8 tst_qqmlproperty: Fix interfaceBinding crash on MSVC 2019
Change-Id: I4bb4a66b7ccca838e058962bbc297659b273c78e
Done-with: Fabian Kosmale <fabian.kosmale@qt.io>
Fixes: QTBUG-84416
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-11-18 17:39:05 +01:00
Maximilian Goldstein 09ea2ca2a7 tst_qqmlproperty: Skip crashing interfaceBinding
Task-number: QTBUG-84416
Change-Id: I79048233041802fe74e28b07def5ca0a3181c358
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-11-17 09:44:08 +01:00
David Faure 4f98bf713f qtdeclarative: finish fixing compilation with explicit QChar(int)
Change-Id: Idb26e2df6d4fe8940db57066a30fa8c243f6d2c9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-07 11:13:39 +01:00
David Skoland e47edfe7a7 Update tests to use new metaType system
Change from the QVariant enum to the QMetaType enum and prefer typeId
over userType where possible

Change-Id: Ic89c55978d46cc23d23b8e9c82c475c0c220fae3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-02 14:56:00 +01:00
Alexandru Croitor 08adbefa13 CMake: Regenerate projects to use new qt_internal_ API
Modify special case locations to use the new API as well.

Task-number: QTBUG-86815
Change-Id: I3b964e3baf0cc7040830156dac30358ea1152801
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-06 13:19:37 +02:00
Fabian Kosmale dc722a1ffb Remove deprecated registration functions
[ChangeLog][QML]
Removed qmlRegisterType overload taking no arguments, use
qmlRegisterAnonymousType instead, or switch to declarative type
registration with QML_ANONYMOUS.
Removed overloads of qmlRegisterExtendedType and qmlRegisterInterface
which did not take a version argument. Use the overloads providing a
version, or swtich to declarative type registration with QML_EXTENDED
and QML_INTERFACE.

Change-Id: Iadcc53d7ebe5cae40856b69efc33293fd0208c1f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-08-27 19:53:58 +02:00
Unai IRIGOYEN 1876bd4215 Add override behaviors to QQmlListProperty
[ChangeLog][QQmlListProperty] When overriding a
QQmlListProperty in a derived QML type, the default behavior is to
append the derived class elements to the base class ones. This
introduces a macro to allow replacing the base
type contents either always or if the property is not the default one.

Fixes: QTBUG-77529
Change-Id: Ib1abbf52e341c043344c347c612928b47856fb3e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-08-22 22:44:32 +02:00
Maximilian Goldstein ad0fd44600 Fix tst_qqmlproperty failures due to stricter QVariant
Change-Id: Ie1f0ee6ae076e50053a19b19e48fe6e996696a69
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2020-08-20 14:57:51 +02:00
Ulf Hermann 0a1e4cc7ec Do not resolve URLs when assigning them to a property
We don't know in advance if a URL is part of the source code and should
be relative to the current element, or if it is part of the application
data and should not be touched.

[ChangeLog][QtQml][Important Behavior Changes] URLs are not resolved or
intercepted anymore when assigning them to a "url" property. Instead
they are resolved and possibly intercepted when used to access an actual
resource.

Fixes: QTBUG-76879
Change-Id: Iaa2385aff2c13aa71a12e57385d9afb5dc60a073
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-06-22 18:37:52 +02:00
Ulf Hermann 8a3f859556 Revert "Decode directory separators in source URLs"
This reverts commit 7ec30c51b287159377761338fe6d3b48706d74ee.

We don't want to half-decode directory separators on assignment. This
just introduces inconsistency down the line.

[ChangeLog][QtQml][Important Behavior Changes] Percent-encoded directory
separators in URLs are not automatically decoded on assignment to url
properties anymore. This was obviously not a good idea to begin with.

Fixes: QTBUG-81244
Change-Id: I1938abbe8aada88beff0d628397674255e8b2472
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-06-22 09:10:18 +02:00
Alexandru Croitor a7c7e7ceaa CMake: Don't install .qmltypes for Qt tests, examples and tools
that don't have an explicit QT_QML_MODULE_INSTALL_DIR path
specified. We don't want to pollute the Qt qml import path with
these files.

Task-number: QTBUG-84403
Change-Id: I768267e0e79daa8090d882c301648cce14e1a809
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-05-29 10:01:40 +02:00
Tor Arne Vestbø a5df29201f CMake: Update Apple platform defines after rename in qtbase
Change-Id: Ia0a075e3199eab735f9b289873beeb8730ebc47e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-17 10:42:00 +01:00
Alexandru Croitor 14492ecee2 CMake: Regenerate and adapt to merge from dev
Change-Id: If8daa6152a563d4309d7342414780ef75b9f5589
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-03-12 14:05:23 +00:00
Alexandru Croitor 26c5243491 Merge remote-tracking branch 'origin/dev' into wip/cmake
Conflicts:
	dependencies.yaml
	src/qml/qml/qqmlengine.cpp

Change-Id: I6a73fd1064286f4a2232de85c2ce7f80452d4641
2020-03-12 15:03:03 +01:00
Qt Forward Merge Bot d5a5e9dcd5 Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	src/qml/jsruntime/qv4engine.cpp

Change-Id: I61f41672e2dfe7e542ca30fed5f173d0a9ee3412
2020-02-13 13:09:47 +01:00
Alexandru Croitor 1d4fa26a70 Regenerate qtdeclarative
Change-Id: I48d7fd306f3d1b161a8e73029282ee591b1ef612
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-02-12 17:30:34 +00:00
Ulf Hermann a2b31f0735 Add a static variant of qmlRegisterInterface()
qmlRegisterInterface() should not be called procedurally, for the same
reason that qmlRegisterType() should not be called procedurally.

Also, add URI and major version parameters to qmlRegisterInterface(),
and deprecate the typeName parameter. We want to identify which import
an interface belongs to.

Task-number: QTBUG-68796
Change-Id: Iba3d66e5ce6219b30aadba34396f12fca92f35a7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-02-12 17:42:11 +01:00
Ulf Hermann 2fae1d7e8f Allow dynamic and static registration of same URI in any order
Previously, a static registration would not go through if a dynamic
registration was carried out before the first type of the statically
registered module was referenced.

Change-Id: Icf6a2b78dff7d0e5b29138501e04723510d6a668
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-02-12 15:45:12 +01:00
Fabian Kosmale 2f4c131805 Fix QQmlProperty and Connections for properties starting with '_'
We do a weird renaming for the change handler of properties starting
with '_', now we do it at least in a consistent way.

Fixes: QTBUG-82017
Change-Id: I1535a5ee462f3a344c972461f1fb954f039aa854
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-02-11 15:45:45 +01:00
Ulf Hermann e4e8b27f1a tst_qqmlproperty: Avoid memory leaks
Change-Id: I38c414edbf75409b3278d89f55f1dbe97fc1fda0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-01-29 15:34:28 +01:00
Leander Beernaert f1f395b37d Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: I48b9c2e4f3a75c18470c55f73f2089dc1401de54
2019-11-25 15:34:40 +01:00
Alexandru Croitor ba494aaa24 Regenerate all projects with new CMake API version
Change-Id: Ie0db35f674137c229eaf049616f38f8e818f7092
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-15 12:24:51 +00:00
Alexandru Croitor 387f360b3b Regenerate tests
Change-Id: I67a6c8f1659e7b471a4fcb92a2699292cf4eea81
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-14 10:22:34 +00:00
Liang Qi 50bce248ab Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
	tests/auto/quick/qquickloader/tst_qquickloader.cpp

Change-Id: I85fd38cfa00cd60197a1c981bfcc16fcb896cfe9
2019-11-07 07:17:40 +01:00
Qt Forward Merge Bot 9c050d4529 Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
	.qmake.conf
	src/qml/common/qv4compileddata_p.h
	src/qml/types/qqmlbind.cpp
	tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp

Change-Id: I6a137907e63445f17a3d6181b832a6bd76135bb2
2019-10-31 09:44:09 +01:00
Fabian Kosmale bcbc3c9cec QQmlProperty: handle reads of QQmlPropertyMap correctly
Fixes: QTBUG-79614
Change-Id: Iaf84c0178dc88072a367da2b42b09554b85c7d57
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-30 11:51:23 +00:00
Qt Forward Merge Bot 328b97a0ac Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	src/qml/qml/qqmlpropertyvalidator.cpp
	tests/auto/qml/qmlmin/tst_qmlmin.cpp

Change-Id: I920c133e839d980ed32c179a0bc4fa44c46e2296
2019-10-24 15:42:35 +02:00
Fabian Kosmale 1eed1b8605 Fix interface handling in bindings
If a type had a property with an interface type, we did not support the
case where the assigned binding value is convertible to the interface.

This is now fixed by adding a last new check to QQmlPrivate::write

Fixes: QTBUG-78721
Change-Id: I0b85fbfdf8561ba43610ac343001ae380287a674
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-10-21 14:38:32 +02:00
Alexandru Croitor c2f8b9535d Merge remote-tracking branch 'origin/dev' into wip/cmake
Removed dependencies.yaml because we don't use it yet in wip/cmake.
Fixed conflict in qmlcachegen.cpp.

Change-Id: Ie1060c737bee1daa85779903598e5b6d5020d922
2019-10-14 19:02:37 +02:00