diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-04-18 01:00:17 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-04-18 08:01:45 +0200 |
commit | 934f25028a232c9bccdb842f53fa67959cc8dffc (patch) | |
tree | a78fef6197d63feab3194eb7f4cd2e10934b18ee /tests/auto/qml/qqmlvaluetypes | |
parent | f8e90c61c5da4ca5e0aec24d42b2962877289ab2 (diff) | |
parent | 2bdbf216fe7b6cf9d404b80ac405bd3969f5c07f (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
src/qml/qml/qqmlimport.cpp
Change-Id: I6add6267297ea50a646d43d212027a168dca8916
Diffstat (limited to 'tests/auto/qml/qqmlvaluetypes')
-rw-r--r-- | tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 8a01524b5b..83a37df797 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -33,6 +33,8 @@ #include <QJSValueIterator> #include <private/qquickvaluetypes_p.h> #include <private/qqmlglobal_p.h> +#include <private/qv4engine_p.h> +#include <private/qv4variantobject_p.h> #include "../../shared/util.h" #include "testtypes.h" @@ -94,6 +96,7 @@ private slots: void toStringConversion(); void enumerableProperties(); void enumProperties(); + void scarceTypes(); private: QQmlEngine engine; @@ -1809,6 +1812,26 @@ void tst_qqmlvaluetypes::enumProperties() QCOMPARE(enumValue.toInt(), int(g.enumProperty())); } +void tst_qqmlvaluetypes::scarceTypes() +{ + // These should not be treated as value types because we want the scarce resource + // mechanism to clear them when going out of scope. The scarce resource mechanism + // only works on QV4::VariantObject as that has an additional level of redirection. + QVERIFY(!QQmlValueTypeFactory::isValueType(qMetaTypeId<QImage>())); + QVERIFY(!QQmlValueTypeFactory::isValueType(qMetaTypeId<QPixmap>())); + + QV4::ExecutionEngine engine; + QV4::Scope scope(&engine); + + QImage img(20, 20, QImage::Format_ARGB32); + QV4::ScopedObject imgValue(scope, engine.fromVariant(QVariant::fromValue(img))); + QCOMPARE(QByteArray(imgValue->vtable()->className), QByteArray("VariantObject")); + + QPixmap pixmap; + QV4::ScopedObject pixmapValue(scope, engine.fromVariant(QVariant::fromValue(img))); + QCOMPARE(QByteArray(pixmapValue->vtable()->className), QByteArray("VariantObject")); +} + QTEST_MAIN(tst_qqmlvaluetypes) |