diff options
21 files changed, 9 insertions, 616 deletions
diff --git a/src/qml/common/qv4compileddata_p.h b/src/qml/common/qv4compileddata_p.h index 8c4aa1b12e..d46fd58bc8 100644 --- a/src/qml/common/qv4compileddata_p.h +++ b/src/qml/common/qv4compileddata_p.h @@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE // Also change the comment behind the number to describe the latest change. This has the added // benefit that if another patch changes the version too, it will result in a merge conflict, and // not get removed silently. -#define QV4_DATA_STRUCTURE_VERSION 0x30// support additional required property features +#define QV4_DATA_STRUCTURE_VERSION 0x31// removed builtin variant type class QIODevice; class QQmlTypeNameCache; @@ -247,7 +247,7 @@ struct Block static_assert(sizeof(Block) == 12, "Block structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); enum class BuiltinType : unsigned int { - Var = 0, Variant, Int, Bool, Real, String, Url, Color, + Var = 0, Int, Bool, Real, String, Url, Color, Font, Time, Date, DateTime, Rect, Point, Size, Vector2D, Vector3D, Vector4D, Matrix4x4, Quaternion, InvalidBuiltin }; diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 8ea97ab956..cadfda0cc3 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -154,7 +154,7 @@ QV4::CompiledData::BuiltinType Parameter::stringToBuiltinType(const QString &typ { "vector4d", strlen("vector4d"), QV4::CompiledData::BuiltinType::Vector4D }, { "quaternion", strlen("quaternion"), QV4::CompiledData::BuiltinType::Quaternion }, { "matrix4x4", strlen("matrix4x4"), QV4::CompiledData::BuiltinType::Matrix4x4 }, - { "variant", strlen("variant"), QV4::CompiledData::BuiltinType::Variant }, + { "variant", strlen("variant"), QV4::CompiledData::BuiltinType::Var }, { "var", strlen("var"), QV4::CompiledData::BuiltinType::Var } }; static const int propTypeNameToTypesCount = sizeof(propTypeNameToTypes) / diff --git a/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc b/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc index ae3337f838..5716f6c386 100644 --- a/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc +++ b/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc @@ -513,101 +513,6 @@ property is only invoked when the property is reassigned to a different object v */ /*! - \obsolete - \qmlbasictype variant - \ingroup qmlbasictypes - \brief a generic property type. - - The \c variant type is a generic property type. It is obsolete and exists only to - support old applications; new applications should use \l var type - properties instead. - - A variant type property can hold any of the \l {QML Basic Types}{basic type} - values: - - \qml - Item { - property variant aNumber: 100 - property variant aString: "Hello world!" - property variant aBool: false - } - \endqml - - When integrating with C++, note that any QVariant value - \l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically - converted into a \c variant value, and vice-versa. - - - \section1 Using Scarce Resources with the variant Type - - A \c variant type property can also hold an image or pixmap. - A \c variant which contains a QPixmap or QImage is known as a - "scarce resource" and the declarative engine will attempt to - automatically release such resources after evaluation of any JavaScript - expression which requires one to be copied has completed. - - Clients may explicitly release such a scarce resource by calling the - "destroy" method on the \c variant property from within JavaScript. They - may also explicitly preserve the scarce resource by calling the - "preserve" method on the \c variant property from within JavaScript. - - \section1 Storing Arrays and Objects - - The \c variant type can also hold: - - \list - \li An array of \l {QML Basic Types}{basic type} values - \li A map of key-value pairs with \l {QML Basic Types}{basic-type} values - \endlist - - For example, below is an \c items array and an \c attributes map. Their - contents can be examined using JavaScript \c for loops. Individual array - values are accessible by index, and individual map values are accessible - by key: - - \qml - Item { - property variant items: [1, 2, 3, "four", "five"] - property variant attributes: { 'color': 'red', 'width': 100 } - - Component.onCompleted: { - for (var i = 0; i < items.length; i++) - console.log(items[i]) - - for (var prop in attributes) - console.log(prop, "=", attributes[prop]) - } - } - \endqml - - While this is a convenient way to store array and map-type values, you - must be aware that the \c items and \c attributes properties above are \e not - QML objects (and certainly not JavaScript object either) and the key-value - pairs in \c attributes are \e not QML properties. Rather, the \c items - property holds an array of values, and \c attributes holds a set of key-value - pairs. - - Additionally, since \c items and \c attributes are not QML objects, changing - the values they contain does not trigger property change notifications. If - the above example had \c onItemsChanged or \c onAttributesChanged signal - handlers, they would not be called when assigning individual entries in - either property. If, however, the \c items or \c attributes properties - themselves were reassigned to different values, then such handlers would be - called. - - JavaScript programmers should also note that when a JavaScript object is - copied to an array or map property, the \e contents of the object (that is, - its key-value properties) are copied, rather than the object itself. The - property does not hold a reference to the original JavaScript object, and - extra data such as the object's JavaScript prototype chain is also lost in - the process. - - This basic type is provided by the QML language. - - \sa {QML Basic Types} -*/ - -/*! \qmlbasictype enumeration \ingroup qmlbasictypes \brief a named enumeration value. diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 11d3dd7b5d..5eb885c2e0 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -423,9 +423,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const QV4::ScopedString s(scope, v4->newString(stringValue)); _vmeMetaObject->setVMEProperty(property->coreIndex(), s); } else { - // ### Qt 6: Doing the conversion here where we don't know the eventual target type is rather strange - // and caused for instance QTBUG-78943 - QVariant value = QQmlStringConverters::variantFromString(stringValue); + QVariant value = stringValue; property->writeProperty(_qobject, &value, propertyWriteFlags); } } diff --git a/src/qml/qml/qqmlpropertycachecreator.cpp b/src/qml/qml/qqmlpropertycachecreator.cpp index 777a698231..144d7e59b4 100644 --- a/src/qml/qml/qqmlpropertycachecreator.cpp +++ b/src/qml/qml/qqmlpropertycachecreator.cpp @@ -50,7 +50,6 @@ int QQmlPropertyCacheCreatorBase::metaTypeForPropertyType(QV4::CompiledData::Bui { switch (type) { case QV4::CompiledData::BuiltinType::Var: return QMetaType::QVariant; - case QV4::CompiledData::BuiltinType::Variant: return QMetaType::QVariant; case QV4::CompiledData::BuiltinType::Int: return QMetaType::Int; case QV4::CompiledData::BuiltinType::Bool: return QMetaType::Bool; case QV4::CompiledData::BuiltinType::Real: return QMetaType::Double; diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h index b98ebebed3..5c9e806a4e 100644 --- a/src/qml/qml/qqmlpropertycachecreator_p.h +++ b/src/qml/qml/qqmlpropertycachecreator_p.h @@ -544,9 +544,6 @@ inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(int if (type != QV4::CompiledData::BuiltinType::InvalidBuiltin) { propertyType = metaTypeForPropertyType(type); - - if (type == QV4::CompiledData::BuiltinType::Variant) - propertyFlags.type = QQmlPropertyData::Flags::QVariantType; } else { Q_ASSERT(!p->isBuiltinType); diff --git a/src/qml/qml/qqmlstringconverters.cpp b/src/qml/qml/qqmlstringconverters.cpp index ba52519eb0..bf291f0549 100644 --- a/src/qml/qml/qqmlstringconverters.cpp +++ b/src/qml/qml/qqmlstringconverters.cpp @@ -48,22 +48,6 @@ QT_BEGIN_NAMESPACE -QVariant QQmlStringConverters::variantFromString(const QString &s) -{ - if (s.isEmpty()) - return QVariant(s); - - bool ok = false; - QRectF r = rectFFromString(s, &ok); - if (ok) return QVariant(r); - QPointF p = pointFFromString(s, &ok); - if (ok) return QVariant(p); - QSizeF sz = sizeFFromString(s, &ok); - if (ok) return QVariant(sz); - - return QQml_valueTypeProvider()->createVariantFromString(s); -} - QVariant QQmlStringConverters::variantFromString(const QString &s, int preferredType, bool *ok) { switch (preferredType) { diff --git a/src/qml/qml/qqmlstringconverters_p.h b/src/qml/qml/qqmlstringconverters_p.h index 215f0c0aaf..d64eb714fd 100644 --- a/src/qml/qml/qqmlstringconverters_p.h +++ b/src/qml/qml/qqmlstringconverters_p.h @@ -66,7 +66,6 @@ class QByteArray; namespace QQmlStringConverters { - Q_QML_PRIVATE_EXPORT QVariant variantFromString(const QString &); Q_QML_PRIVATE_EXPORT QVariant variantFromString(const QString &, int preferredType, bool *ok = nullptr); Q_QML_PRIVATE_EXPORT QVariant colorFromString(const QString &, bool *ok = nullptr); diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index fbfc387cc6..b946027b8d 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -734,9 +734,6 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * case QV4::CompiledData::BuiltinType::Point: *reinterpret_cast<QPointF *>(a[0]) = readPropertyAsPointF(id); break; - case QV4::CompiledData::BuiltinType::Variant: - *reinterpret_cast<QVariant *>(a[0]) = readPropertyAsVariant(id); - break; case QV4::CompiledData::BuiltinType::Font: case QV4::CompiledData::BuiltinType::Time: case QV4::CompiledData::BuiltinType::Color: @@ -842,9 +839,6 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * needActivate = *reinterpret_cast<QPointF *>(a[0]) != readPropertyAsPointF(id); writeProperty(id, *reinterpret_cast<QPointF *>(a[0])); break; - case QV4::CompiledData::BuiltinType::Variant: - writeProperty(id, *reinterpret_cast<QVariant *>(a[0])); - break; case QV4::CompiledData::BuiltinType::Font: case QV4::CompiledData::BuiltinType::Time: case QV4::CompiledData::BuiltinType::Color: diff --git a/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml b/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml index d97613a875..ec6f8b32c5 100644 --- a/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml +++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml @@ -1,8 +1,6 @@ import Qt.test 1.0 MyQmlObject { - property variant a: function myFunction() { return 2; } - property variant b: Qt.binding(function() { return 2; }) property var c: Qt.binding(function() { return 2; }) qjsvalue: Qt.binding(function() { return 2; }) } diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml index 99c49ebf62..77d8161138 100644 --- a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml @@ -17,54 +17,36 @@ Item { property bool success: false - property variant intList - property variant qrealList - property variant boolList - property variant stringList - function indexedAccess() { - intList = msco.intListProperty; var jsIntList = msco.intListProperty; - qrealList = msco.qrealListProperty; var jsQrealList = msco.qrealListProperty; - boolList = msco.boolListProperty; var jsBoolList = msco.boolListProperty; - stringList = msco.stringListProperty; var jsStringList = msco.stringListProperty; - // Three cases: direct property modification, variant copy modification, js var reference modification. - // Only the first and third should "write back" to the original QObject Q_PROPERTY; the second one - // should have no effect whatsoever to maintain "property variant" semantics (see e.g., valuetype). + // Two cases: direct property modification, js var reference modification. + // Both should "write back" to the original QObject Q_PROPERTY success = true; msco.intListProperty[1] = 33; if (msco.intListProperty[1] != 33) success = false; // ensure write back - intList[1] = 44; - if (intList[1] == 44) success = false; // ensure no effect jsIntList[1] = 55; if (jsIntList[1] != 55 || jsIntList[1] != msco.intListProperty[1]) success = false; // ensure write back msco.qrealListProperty[1] = 33.3; if (msco.qrealListProperty[1] != 33.3) success = false; // ensure write back - qrealList[1] = 44.4; - if (qrealList[1] == 44.4) success = false; // ensure no effect jsQrealList[1] = 55.5; if (jsQrealList[1] != 55.5 || jsQrealList[1] != msco.qrealListProperty[1]) success = false; // ensure write back msco.boolListProperty[1] = true; if (msco.boolListProperty[1] != true) success = false; // ensure write back - boolList[1] = true; - if (boolList[1] != false) success = false; // ensure no effect jsBoolList[1] = false; if (jsBoolList[1] != false || jsBoolList[1] != msco.boolListProperty[1]) success = false; // ensure write back msco.stringListProperty[1] = "changed"; if (msco.stringListProperty[1] != "changed") success = false; // ensure write back - stringList[1] = "changed"; - if (stringList[1] != "second") success = false; // ensure no effect jsStringList[1] = "different"; if (jsStringList[1] != "different" || jsStringList[1] != msco.stringListProperty[1]) success = false; // ensure write back diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.copy.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.copy.qml deleted file mode 100644 index 088e240ad4..0000000000 --- a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.copy.qml +++ /dev/null @@ -1,183 +0,0 @@ -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: root - objectName: "root" - - MySequenceConversionObject { - id: msco - objectName: "msco" - } - - property bool success: true - - property variant intList - property variant qrealList - property variant boolList - property variant stringList - property variant urlList - property variant qstringList - - // this test ensures that the "copy resource" codepaths work - function testCopySequences() { - success = true; - - // create "copy resource" sequences - var jsIntList = msco.generateIntSequence(); - var jsQrealList = msco.generateQrealSequence(); - var jsBoolList = msco.generateBoolSequence(); - var jsStringList = msco.generateStringSequence(); - var jsUrlList = msco.generateUrlSequence(); - var jsQStringList = msco.generateQStringSequence(); - - if (jsIntList.toString() != [1, 2, 3].toString()) - success = false; - if (jsQrealList.toString() != [1.1, 2.2, 3.3].toString()) - success = false; - if (jsBoolList.toString() != [true, false, true].toString()) - success = false; - if (jsStringList.toString() != ["one", "two", "three"].toString()) - success = false; - if (jsUrlList.toString() != ["http://www.example1.com", "http://www.example2.com", "http://www.example3.com"].toString()) - success = false; - if (jsQStringList.toString() != ["one", "two", "three"].toString()) - success = false; - - // copy the sequence; should result in a new copy - intList = jsIntList; - qrealList = jsQrealList; - boolList = jsBoolList; - stringList = jsStringList; - urlList = jsUrlList; - qstringList = jsQStringList; - - // these operations shouldn't modify either variables - because - // we don't handle writing to the intermediate variant at list[index] - // for variant properties. - intList[1] = 8; - qrealList[1] = 8.8; - boolList[1] = true; - stringList[1] = "eight"; - urlList[1] = "http://www.example8.com"; - qstringList[1] = "eight"; - - if (jsIntList[1] == 8) - success = false; - if (jsQrealList[1] == 8.8) - success = false; - if (jsBoolList[1] == true) - success = false; - if (jsStringList[1] == "eight") - success = false; - if (jsUrlList[1] == "http://www.example8.com") - success = false; - if (jsQStringList[1] == "eight") - success = false; - - // assign a "copy resource" sequence to a QObject Q_PROPERTY - msco.intListProperty = intList; - msco.qrealListProperty = qrealList; - msco.boolListProperty = boolList; - msco.stringListProperty = stringList; - msco.urlListProperty = urlList; - msco.qstringListProperty = qstringList; - - if (msco.intListProperty.toString() != [1, 2, 3].toString()) - success = false; - if (msco.qrealListProperty.toString() != [1.1, 2.2, 3.3].toString()) - success = false; - if (msco.boolListProperty.toString() != [true, false, true].toString()) - success = false; - if (msco.stringListProperty.toString() != ["one", "two", "three"].toString()) - success = false; - if (msco.urlListProperty.toString() != ["http://www.example1.com", "http://www.example2.com", "http://www.example3.com"].toString()) - success = false; - if (msco.qstringListProperty.toString() != ["one", "two", "three"].toString()) - success = false; - - // now modify the QObject Q_PROPERTY (reference resource) sequences - shouldn't modify the copy resource sequences. - msco.intListProperty[2] = 9; - msco.qrealListProperty[2] = 9.9; - msco.boolListProperty[2] = false; - msco.stringListProperty[2] = "nine"; - msco.urlListProperty[2] = "http://www.example9.com"; - msco.qstringListProperty[2] = "nine"; - - if (intList[2] == 9) - success = false; - if (qrealList[2] == 9.9) - success = false; - if (boolList[2] == false) - success = false; - if (stringList[2] == "nine") - success = false; - if (urlList[2] == "http://www.example9.com") - success = false; - if (qstringList[2] == "nine") - success = false; - } - - property int intVal - property real qrealVal - property bool boolVal - property string stringVal - - // this test ensures that indexed access works for copy resource sequences. - function readSequenceCopyElements() { - success = true; - - var jsIntList = msco.generateIntSequence(); - var jsQrealList = msco.generateQrealSequence(); - var jsBoolList = msco.generateBoolSequence(); - var jsStringList = msco.generateStringSequence(); - - intVal = jsIntList[1]; - qrealVal = jsQrealList[1]; - boolVal = jsBoolList[1]; - stringVal = jsStringList[1]; - - if (intVal != 2) - success = false; - if (qrealVal != 2.2) - success = false; - if (boolVal != false) - success = false; - if (stringVal != "two") - success = false; - } - - // this test ensures that equality works for copy resource sequences. - function testEqualitySemantics() { - success = true; - - var jsIntList = msco.generateIntSequence(); - var jsIntList2 = msco.generateIntSequence(); - - if (jsIntList == jsIntList2) success = false; - if (jsIntList != jsIntList) success = false; - } - - // this test ensures that copy resource sequences can be passed as parameters - function testCopyParameters() { - success = false; - - var jsIntList = msco.generateIntSequence(); - success = msco.parameterEqualsGeneratedIntSequence(jsIntList); - if (success == false) return; - - // here we construct something which should be converted to a copy sequence automatically. - success = msco.parameterEqualsGeneratedIntSequence([1,2,3]); - } - - // this test ensures that reference resource sequences are converted - // to copy resource sequences when passed as parameters. - function testReferenceParameters() { - success = false; - - msco.intListProperty = msco.generateIntSequence(); - var jsIntList = msco.intListProperty - success = msco.parameterEqualsGeneratedIntSequence(jsIntList); - if (success == false) return; - } -} diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index deb949e7a5..374819a3fe 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -205,7 +205,6 @@ private slots: void sequenceConversionIndexes(); void sequenceConversionThreads(); void sequenceConversionBindings(); - void sequenceConversionCopy(); void assignSequenceTypes(); void sequenceSort_data(); void sequenceSort(); @@ -4887,94 +4886,6 @@ void tst_qqmlecmascript::scarceResources_data() << (QList<QVariant>() << false << false) // invalidating one should invalidate the other, because they're references to the same JS object. << (QList<QVariant>() << QVariant() << QVariant()) << QStringList(); - - - /* property variant semantics */ - - // in the following three cases, the instance created from the component - // has a property which is a copy of the scarce resource; hence, the - // resource should NOT be detached prior to deletion of the object instance, - // unless the resource is destroyed explicitly. - QTest::newRow("variant: import scarce resource copy directly") - << testFileUrl("scarceResourceCopy.variant.qml") - << true - << false // won't be detached, because assigned to property and not explicitly released - << (QStringList() << QLatin1String("scarceResourceCopy")) - << (QList<QVariant>() << true) - << (QList<QVariant>() << origPixmap) - << QStringList(); - - QTest::newRow("variant: import scarce resource copy from JS") - << testFileUrl("scarceResourceCopyFromJs.variant.qml") - << true - << false // won't be detached, because assigned to property and not explicitly released - << (QStringList() << QLatin1String("scarceResourceCopy")) - << (QList<QVariant>() << true) - << (QList<QVariant>() << origPixmap) - << QStringList(); - - QTest::newRow("variant: import released scarce resource copy from JS") - << testFileUrl("scarceResourceDestroyedCopy.variant.qml") - << true - << true // explicitly released, so it will be detached - << (QStringList() << QLatin1String("scarceResourceCopy")) - << (QList<QVariant>() << false) - << (QList<QVariant>() << QVariant()) - << QStringList(); - - // in the following three cases, no other copy should exist in memory, - // and so it should be detached (unless explicitly preserved). - QTest::newRow("variant: import auto-release SR from JS in binding side-effect") - << testFileUrl("scarceResourceTest.variant.qml") - << true - << true // auto released, so it will be detached - << (QStringList() << QLatin1String("scarceResourceTest")) - << (QList<QVariant>() << true) - << (QList<QVariant>() << QVariant(100)) - << QStringList(); - QTest::newRow("variant: import explicit-preserve SR from JS in binding side-effect") - << testFileUrl("scarceResourceTestPreserve.variant.qml") - << true - << false // won't be detached because we explicitly preserve it - << (QStringList() << QLatin1String("scarceResourceTest")) - << (QList<QVariant>() << true) - << (QList<QVariant>() << QVariant(100)) - << QStringList(); - QTest::newRow("variant: import multiple scarce resources") - << testFileUrl("scarceResourceTestMultiple.variant.qml") - << true - << true // will be detached because all resources were released manually or automatically. - << (QStringList() << QLatin1String("scarceResourceTest")) - << (QList<QVariant>() << true) - << (QList<QVariant>() << QVariant(100)) - << QStringList(); - - // In the following three cases, test that scarce resources are handled - // correctly for imports. - QTest::newRow("variant: import with no binding") - << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml") - << false // cannot check detach status. - << false - << QStringList() - << QList<QVariant>() - << QList<QVariant>() - << QStringList(); - QTest::newRow("variant: import with binding without explicit preserve") - << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml") - << false - << false - << (QStringList() << QLatin1String("scarceResourceCopy")) - << (QList<QVariant>() << false) // will have been released prior to evaluation of binding. - << (QList<QVariant>() << QVariant()) - << QStringList(); - QTest::newRow("variant: import with explicit release after binding evaluation") - << testFileUrl("scarceResourceCopyImport.variant.qml") - << false - << false - << (QStringList() << QLatin1String("scarceResourceImportedCopy") << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo")) - << (QList<QVariant>() << true << true << false) // since property variant = variant copy, releasing the provider's resource does not invalidate previously assigned copies. - << (QList<QVariant>() << origPixmap << origPixmap << QVariant()) - << QStringList(); } void tst_qqmlecmascript::scarceResources() @@ -5923,26 +5834,6 @@ void tst_qqmlecmascript::sequenceConversionBindings() } } -void tst_qqmlecmascript::sequenceConversionCopy() -{ - QUrl qmlFile = testFileUrl("sequenceConversion.copy.qml"); - QQmlEngine engine; - QQmlComponent component(&engine, qmlFile); - QObject *object = component.create(); - QVERIFY(object != nullptr); - QMetaObject::invokeMethod(object, "testCopySequences"); - QCOMPARE(object->property("success").toBool(), true); - QMetaObject::invokeMethod(object, "readSequenceCopyElements"); - QCOMPARE(object->property("success").toBool(), true); - QMetaObject::invokeMethod(object, "testEqualitySemantics"); - QCOMPARE(object->property("success").toBool(), true); - QMetaObject::invokeMethod(object, "testCopyParameters"); - QCOMPARE(object->property("success").toBool(), true); - QMetaObject::invokeMethod(object, "testReferenceParameters"); - QCOMPARE(object->property("success").toBool(), true); - delete object; -} - void tst_qqmlecmascript::assignSequenceTypes() { QQmlEngine engine; @@ -6317,19 +6208,14 @@ void tst_qqmlecmascript::functionAssignment_fromBinding() QQmlComponent component(&engine, testFileUrl("functionAssignment.1.qml")); QString url = component.url().toString(); - QString w1 = url + ":4:5: Unable to assign a function to a property of any type other than var."; + QString w1 = url + ":4:5: Invalid use of Qt.binding() in a binding declaration."; QString w2 = url + ":5:5: Invalid use of Qt.binding() in a binding declaration."; - QString w3 = url + ":6:5: Invalid use of Qt.binding() in a binding declaration."; - QString w4 = url + ":7:5: Invalid use of Qt.binding() in a binding declaration."; QTest::ignoreMessage(QtWarningMsg, w1.toLatin1().constData()); QTest::ignoreMessage(QtWarningMsg, w2.toLatin1().constData()); - QTest::ignoreMessage(QtWarningMsg, w3.toLatin1().constData()); - QTest::ignoreMessage(QtWarningMsg, w4.toLatin1().constData()); MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(o != nullptr); - QVERIFY(!o->property("a").isValid()); delete o; } diff --git a/tests/auto/qml/qqmllanguage/data/assignLiteralToVariant.qml b/tests/auto/qml/qqmllanguage/data/assignLiteralToVariant.qml deleted file mode 100644 index f6f9a139dc..0000000000 --- a/tests/auto/qml/qqmllanguage/data/assignLiteralToVariant.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property variant test1: 1 - property variant test2: 1.7 - property variant test3: "Hello world!" - property variant test4: "#FF008800" - property variant test5: "10,10,10x10" - property variant test6: "10,10" - property variant test7: "10x10" - property variant test8: "100,100,100" - property variant test9: String("#FF008800") - property variant test10: true - property variant test11: false - property variant test12: "100,100,100,100" -} - diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index e5ac59f379..2932b112e3 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -104,7 +104,6 @@ private slots: void assignBasicTypes(); void assignTypeExtremes(); void assignCompositeToType(); - void assignLiteralToVariant(); void assignLiteralToVar(); void assignLiteralToJSValue(); void assignNullStrings(); @@ -849,41 +848,6 @@ void tst_qqmllanguage::assignCompositeToType() QVERIFY(object != nullptr); } -// Test that literals are stored correctly in variant properties -void tst_qqmllanguage::assignLiteralToVariant() -{ - QQmlComponent component(&engine, testFileUrl("assignLiteralToVariant.qml")); - VERIFY_ERRORS(0); - QScopedPointer<QObject> object(component.create()); - QVERIFY(object != nullptr); - - QVERIFY(isJSNumberType(object->property("test1").userType())); - QVERIFY(isJSNumberType(object->property("test2").userType())); - QCOMPARE(object->property("test3").userType(), (int)QVariant::String); - QCOMPARE(object->property("test4").userType(), (int)QVariant::Color); - QCOMPARE(object->property("test5").userType(), (int)QVariant::RectF); - QCOMPARE(object->property("test6").userType(), (int)QVariant::PointF); - QCOMPARE(object->property("test7").userType(), (int)QVariant::SizeF); - QCOMPARE(object->property("test8").userType(), (int)QVariant::Vector3D); - QCOMPARE(object->property("test9").userType(), (int)QVariant::String); - QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool); - QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool); - QCOMPARE(object->property("test12").userType(), (int)QVariant::Vector4D); - - QCOMPARE(object->property("test1"), QVariant(1)); - QCOMPARE(object->property("test2"), QVariant((double)1.7)); - QVERIFY(object->property("test3") == QVariant(QString(QLatin1String("Hello world!")))); - QCOMPARE(object->property("test4"), QVariant(QColor::fromRgb(0xFF008800))); - QVERIFY(object->property("test5") == QVariant(QRectF(10, 10, 10, 10))); - QVERIFY(object->property("test6") == QVariant(QPointF(10, 10))); - QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10))); - QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100))); - QCOMPARE(object->property("test9"), QVariant(QString(QLatin1String("#FF008800")))); - QCOMPARE(object->property("test10"), QVariant(bool(true))); - QCOMPARE(object->property("test11"), QVariant(bool(false))); - QVERIFY(object->property("test12") == QVariant(QVector4D(100, 100, 100, 100))); -} - // Test that literals are stored correctly in "var" properties // Note that behaviour differs from "variant" properties in that // no conversion from "special strings" to QVariants is performed. @@ -3560,6 +3524,7 @@ void tst_qqmllanguage::variantNotify() QScopedPointer<QObject> object(component.create()); QVERIFY(object != nullptr); + QEXPECT_FAIL("", "var properties always trigger notify", Continue); QCOMPARE(object->property("notifyCount").toInt(), 1); } diff --git a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp index b21d2a908d..7b02415328 100644 --- a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp +++ b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp @@ -115,12 +115,6 @@ void tst_QQmlMetaObject::property_data() << QVariant(QDate(2012, 2, 7).startOfDay()) << true // writable << QVariant(QDate(2010, 7, 2).startOfDay()); - QTest::newRow("variant") << "property.variant.qml" - << QByteArray("QVariant") << int(QMetaType::QVariant) - << true // default - << QVariant(QPointF(12, 34)) - << true // writable - << QVariant(QSizeF(45, 67)); QTest::newRow("var") << "property.var.qml" << QByteArray("QVariant") << int(QMetaType::QVariant) << false // default diff --git a/tests/auto/qml/qqmlvaluetypes/data/variant_read.qml b/tests/auto/qml/qqmlvaluetypes/data/variant_read.qml deleted file mode 100644 index a08f3db94f..0000000000 --- a/tests/auto/qml/qqmlvaluetypes/data/variant_read.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property real s_width: variant.width - property real s_height: variant.height - property variant copy: variant -} - - diff --git a/tests/auto/qml/qqmlvaluetypes/data/variant_write.1.qml b/tests/auto/qml/qqmlvaluetypes/data/variant_write.1.qml deleted file mode 100644 index 6063917dd4..0000000000 --- a/tests/auto/qml/qqmlvaluetypes/data/variant_write.1.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.0 - -Item { - property bool complete: false - property bool success: false - - property variant v1: Qt.vector3d(1,2,3) - property variant v2: Qt.vector3d(4,5,6) - property variant v3: v1.plus(v2) // set up doomed binding - - Component.onCompleted: { - complete = false; - success = true; - - v1 = Qt.vector2d(1,2) // changing the type of the property shouldn't cause crash - - v1.x = 8; - v2.x = 9; - - if (v1 != Qt.vector2d(8,2)) success = false; - if (v2 != Qt.vector3d(9,5,6)) success = false; - - complete = true; - } -} diff --git a/tests/auto/qml/qqmlvaluetypes/data/variant_write.2.qml b/tests/auto/qml/qqmlvaluetypes/data/variant_write.2.qml deleted file mode 100644 index 0dbfd2a012..0000000000 --- a/tests/auto/qml/qqmlvaluetypes/data/variant_write.2.qml +++ /dev/null @@ -1,40 +0,0 @@ -import QtQuick 2.0 - -Item { - property bool complete: false - property bool success: false - - property variant v1 - - Component.onCompleted: { - complete = false; - success = true; - - // store a js reference to the VariantReference vt in a temp var. - v1 = Qt.vector3d(1,2,3) - var ref = v1; - ref.z = 5 - if (v1 != Qt.vector3d(1,2,5)) success = false; - - // now change the type of a reference, and attempt a valid write. - v1 = Qt.vector2d(1,2); - ref.x = 5; - if (v1 != Qt.vector2d(5,2)) success = false; - - // now change the type of a reference, and attempt an invalid write. - v1 = Qt.rgba(1,0,0,1); - ref.x = 5; - if (v1.toString() != Qt.rgba(1,0,0,1).toString()) success = false; - v1 = 6; - ref.x = 5; - if (v1 != 6) success = false; - - // now change the type of a reference, and attempt an invalid read. - v1 = Qt.vector3d(1,2,3); - ref = v1; - v1 = Qt.vector2d(1,2); - if (ref.z == 3) success = false; - - complete = true; - } -} diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index f2e43571d8..317a3bd152 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -65,7 +65,6 @@ private slots: void matrix4x4(); void font(); void color(); - void variant(); void locale(); void qmlproperty(); @@ -290,39 +289,6 @@ void tst_qqmlvaluetypes::sizef() } } -void tst_qqmlvaluetypes::variant() -{ - { - QQmlComponent component(&engine, testFileUrl("variant_read.qml")); - MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); - QVERIFY(object != nullptr); - - QCOMPARE(float(object->property("s_width").toDouble()), float(0.1)); - QCOMPARE(float(object->property("s_height").toDouble()), float(100923.2)); - QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2))); - - delete object; - } - - { - QQmlComponent component(&engine, testFileUrl("variant_write.1.qml")); - QObject *object = component.create(); - QVERIFY(object != nullptr); - QVERIFY(object->property("complete").toBool()); - QVERIFY(object->property("success").toBool()); - delete object; - } - - { - QQmlComponent component(&engine, testFileUrl("variant_write.2.qml")); - QObject *object = component.create(); - QVERIFY(object != nullptr); - QVERIFY(object->property("complete").toBool()); - QVERIFY(object->property("success").toBool()); - delete object; - } -} - void tst_qqmlvaluetypes::locale() { { diff --git a/tests/auto/quick/qquickpincharea/data/pinchproperties.qml b/tests/auto/quick/qquickpincharea/data/pinchproperties.qml index c5daf6cbfe..899c6380da 100644 --- a/tests/auto/quick/qquickpincharea/data/pinchproperties.qml +++ b/tests/auto/quick/qquickpincharea/data/pinchproperties.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 Rectangle { id: whiteRect - property variant center + property point center property real scale: -1.0 property int pointCount: 0 property bool pinchActive: false |