diff options
Diffstat (limited to 'src/qml/qml/v4/qv4bindings.cpp')
-rw-r--r-- | src/qml/qml/v4/qv4bindings.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/qml/qml/v4/qv4bindings.cpp b/src/qml/qml/v4/qv4bindings.cpp index db015b07d6..e055cad4f2 100644 --- a/src/qml/qml/v4/qv4bindings.cpp +++ b/src/qml/qml/v4/qv4bindings.cpp @@ -46,6 +46,7 @@ #include "qv4compiler_p.h" #include "qv4compiler_p_p.h" +#include <private/qqmlglobal_p.h> #include <private/qqmlaccessors_p.h> #include <private/qqmlprofilerservice_p.h> #include <private/qqmlmetatype_p.h> @@ -93,12 +94,11 @@ struct Register { inline QVariant *getvariantptr() { return (QVariant *)typeDataPtr(); } inline QString *getstringptr() { return (QString *)typeDataPtr(); } inline QUrl *geturlptr() { return (QUrl *)typeDataPtr(); } - inline QColor *getcolorptr() { return (QColor *)typeDataPtr(); } inline const QVariant *getvariantptr() const { return (QVariant *)typeDataPtr(); } inline const QString *getstringptr() const { return (QString *)typeDataPtr(); } inline const QUrl *geturlptr() const { return (QUrl *)typeDataPtr(); } - inline const QColor *getcolorptr() const { return (QColor *)typeDataPtr(); } + size_t dataSize() { return sizeof(data); } inline void *typeDataPtr() { return (void *)&data; } inline void *typeMemory() { return (void *)data; } inline const void *typeDataPtr() const { return (void *)&data; } @@ -147,7 +147,7 @@ void Register::cleanup() } else if (dataType == QUrlType) { geturlptr()->~QUrl(); } else if (dataType == QColorType) { - getcolorptr()->~QColor(); + QQml_valueTypeProvider()->destroyValueType(QMetaType::QColor, typeDataPtr(), dataSize()); } else if (dataType == QVariantType) { getvariantptr()->~QVariant(); } @@ -169,7 +169,7 @@ void Register::cleanupUrl() void Register::cleanupColor() { - getcolorptr()->~QColor(); + QQml_valueTypeProvider()->destroyValueType(QMetaType::QColor, typeDataPtr(), dataSize()); setUndefined(); } @@ -188,7 +188,7 @@ void Register::copy(const Register &other) else if (other.dataType == QUrlType) new (geturlptr()) QUrl(*other.geturlptr()); else if (other.dataType == QColorType) - new (getcolorptr()) QColor(*other.getcolorptr()); + QQml_valueTypeProvider()->copyValueType(QMetaType::QColor, other.typeDataPtr(), typeDataPtr(), dataSize()); else if (other.dataType == QVariantType) new (getvariantptr()) QVariant(*other.getvariantptr()); } @@ -203,7 +203,7 @@ void Register::init(Type type) else if (dataType == QUrlType) new (geturlptr()) QUrl(); else if (dataType == QColorType) - new (getcolorptr()) QColor(); + QQml_valueTypeProvider()->initValueType(QMetaType::QColor, typeDataPtr(), dataSize()); else if (dataType == QVariantType) new (getvariantptr()) QVariant(); } @@ -507,7 +507,7 @@ static void testBindingResult(const QString &binding, int line, int column, v4value = result.getnumber(); break; case QMetaType::QColor: - v4value = *result.getcolorptr(); + v4value = QVariant(QMetaType::QColor, result.typeDataPtr()); break; case QMetaType::QVariant: v4value = *result.getvariantptr(); @@ -1085,8 +1085,7 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks, output.cleanupString(); MARK_CLEAN_REGISTER(instr->unaryop.output); } - QColor *colorPtr = output.getcolorptr(); - new (colorPtr) QColor(QQmlStringConverters::colorFromString(tmp)); + QQml_valueTypeProvider()->createValueFromString(QMetaType::QColor, tmp, output.typeDataPtr(), output.dataSize()); COLOR_REGISTER(instr->unaryop.output); } @@ -1190,13 +1189,7 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks, if (src.isUndefined()) { output.setUndefined(); } else { - const QColor tmp(*src.getcolorptr()); - if (instr->unaryop.src == instr->unaryop.output) { - output.cleanupColor(); - MARK_CLEAN_REGISTER(instr->unaryop.output); - } - // to maintain behaviour with QtQuick 1.0, we just output normal toString() value. - new (output.getstringptr()) QString(QVariant(tmp).toString()); + QQml_valueTypeProvider()->createStringFromValue(QMetaType::QColor, src.typeDataPtr(), output.getstringptr()); STRING_REGISTER(instr->unaryop.output); } } @@ -1210,7 +1203,7 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks, if (src.isUndefined()) { output.setUndefined(); } else { - const QColor tmp(*src.getcolorptr()); + QVariant tmp(QMetaType::QColor, src.typeDataPtr()); if (instr->unaryop.src == instr->unaryop.output) { output.cleanupColor(); MARK_CLEAN_REGISTER(instr->unaryop.output); |