diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-09-18 16:17:42 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-09-23 14:54:47 +0200 |
commit | 39b5be920cf65979df669d02a3410a7396be6ada (patch) | |
tree | 26f91a48ed294e48b907e0a8a98b2ad6baf187f0 /src | |
parent | 55158d25127173f4a96f2fa70fa7603fa81f8bd9 (diff) |
Eliminate QQmlValueTypeProvider::storeValueType()
It was only used for QColor. The string representation of QColor was
funneled through the color provider to get a numerical RGBA value and
that one was passed to storeValueType() which would create a QColor
object. The RGBA value was retrieved by creating a QColor object. We
can just directly create the QColor from the string, and we can use the
generic create() method for that.
Change-Id: If36775830882237e5e36f748872ce23530c3bb71
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlglobal.cpp | 15 | ||||
-rw-r--r-- | src/qml/qml/qqmlglobal_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 10 | ||||
-rw-r--r-- | src/quick/util/qquickglobal.cpp | 28 |
4 files changed, 4 insertions, 51 deletions
diff --git a/src/qml/qml/qqmlglobal.cpp b/src/qml/qml/qqmlglobal.cpp index 73cc9abc93..22a87c2eec 100644 --- a/src/qml/qml/qqmlglobal.cpp +++ b/src/qml/qml/qqmlglobal.cpp @@ -115,20 +115,6 @@ bool QQmlValueTypeProvider::equalValueType(int type, const void *lhs, const QVar return QMetaType(type).equals(lhs, rhs.constData()); } -bool QQmlValueTypeProvider::storeValueType(int type, const void *src, void *dst, size_t dstSize) -{ - Q_ASSERT(src); - Q_ASSERT(dst); - - QQmlValueTypeProvider *p = this; - do { - if (p->store(type, src, dst, dstSize)) - return true; - } while ((p = p->next)); - - return false; -} - bool QQmlValueTypeProvider::readValueType(const QVariant& src, void *dst, int type) { Q_ASSERT(dst); @@ -153,7 +139,6 @@ bool QQmlValueTypeProvider::writeValueType(int type, const void *src, QVariant& } bool QQmlValueTypeProvider::create(int, const QJSValue &, QVariant *) { return false; } -bool QQmlValueTypeProvider::store(int, const void *, void *, size_t) { return false; } struct ValueTypeProviderList { QQmlValueTypeProvider nullProvider; diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h index 722a3f4989..5caa8e7d29 100644 --- a/src/qml/qml/qqmlglobal_p.h +++ b/src/qml/qml/qqmlglobal_p.h @@ -229,13 +229,11 @@ public: QVariant createVariantFromJsObject(int, const QJSValue &, bool *); bool equalValueType(int, const void *, const QVariant&); - bool storeValueType(int, const void *, void *, size_t); bool readValueType(const QVariant&, void *, int); bool writeValueType(int, const void *, QVariant&); private: virtual bool create(int, const QJSValue ¶ms, QVariant *); - virtual bool store(int, const void *, void *, size_t); friend Q_QML_PRIVATE_EXPORT void QQml_addValueTypeProvider(QQmlValueTypeProvider *); friend Q_QML_PRIVATE_EXPORT void QQml_removeValueTypeProvider(QQmlValueTypeProvider *); diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 310f8579bf..809d1c4976 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -483,12 +483,10 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const } break; case QMetaType::QColor: { - bool ok = false; - uint colorValue = QQmlStringConverters::rgbaFromString(compilationUnit->bindingValueAsString(binding), &ok); - assertOrNull(ok); - struct { void *data[4]; } buffer; - if (QQml_valueTypeProvider()->storeValueType(property->propType(), &colorValue, &buffer, sizeof(buffer))) { - property->writeProperty(_qobject, &buffer, propertyWriteFlags); + QVariant data; + if (QQml_valueTypeProvider()->createValueFromString( + QMetaType::QColor, compilationUnit->bindingValueAsString(binding), &data)) { + property->writeProperty(_qobject, data.data(), propertyWriteFlags); } } break; diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp index 90b3139b33..c12137efe3 100644 --- a/src/quick/util/qquickglobal.cpp +++ b/src/quick/util/qquickglobal.cpp @@ -670,34 +670,6 @@ public: return false; } - template<typename T> - bool typedStore(const void *src, void *dst, size_t dstSize) - { - ASSERT_VALID_SIZE(dstSize, sizeof(T)); - const T *srcT = reinterpret_cast<const T *>(src); - T *dstT = reinterpret_cast<T *>(dst); - new (dstT) T(*srcT); - return true; - } - - bool store(int type, const void *src, void *dst, size_t dstSize) override - { - Q_UNUSED(dstSize); - switch (type) { - case QMetaType::QColor: - { - Q_ASSERT(dstSize >= sizeof(QColor)); - const QRgb *rgb = reinterpret_cast<const QRgb *>(src); - QColor *color = reinterpret_cast<QColor *>(dst); - new (color) QColor(QColor::fromRgba(*rgb)); - return true; - } - default: break; - } - - return false; - } - #undef ASSERT_VALID_SIZE }; |