diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-01-08 15:00:03 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-01-09 07:33:03 +0000 |
commit | 2e8a45d99f94cbd2c805dd3de56d60d9baa9bd4e (patch) | |
tree | 88d0fde77a9d61eb999f7c6d0b614eb685a5fe51 /src/qml/qml/qqmlbinding.cpp | |
parent | 590e7418cc6afbf2b5b8cf85373f1674c583a7da (diff) |
Fix regression with simple qsTr() bindings on non-string properties
Commit 61887379b0c823953b61120532055fcbd881aadd introduced an
optimization to avoid lengthy JS evaluation for simple qsTr("constant
string") bindings. Unfortunately it missed the case that the binding is
_not_ to a QString "native" property, resulting in memory corruption:
property var str: qsTr("sometimes")
... where QQmlVMEMetaObject's metacall would expect the void *arg to be
a QVariant and the translation binding would "deliver" a QString
pointer.
[ChangeLog[Qt][Qml] Fix crash with simple qsTr() bindings on var
properties.
Change-Id: I8d35eecbf6697fb3e3ad184389deb81890b08e29
Task-number: QTBUG-65624
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlbinding.cpp')
-rw-r--r-- | src/qml/qml/qqmlbinding.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 566fbb86ac..9453e6480b 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -307,7 +307,7 @@ public: } void doUpdate(const DeleteWatcher &watcher, - QQmlPropertyData::WriteFlags flags, QV4::Scope &) Q_DECL_OVERRIDE Q_DECL_FINAL + QQmlPropertyData::WriteFlags flags, QV4::Scope &scope) Q_DECL_OVERRIDE Q_DECL_FINAL { if (watcher.wasDeleted()) return; @@ -323,7 +323,12 @@ public: QQmlPropertyData vpd; getPropertyData(&pd, &vpd); Q_ASSERT(pd); - doStore(result, pd, flags); + if (pd->propType() == QMetaType::QString) { + doStore(result, pd, flags); + } else { + QV4::ScopedString value(scope, scope.engine->newString(result)); + slowWrite(*pd, vpd, value, /*isUndefined*/false, flags); + } } private: |