aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-01-19 14:14:50 +0100
committerGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-02-04 10:34:35 +0000
commitb962b5281b3c90cacc00db8b8b69bcff730a0093 (patch)
tree9fccad84ff113de036acb003551ce7d8464a0f6d /src
parenta2854322a27e4e06530721fdc79a7bf71e33ee42 (diff)
QQmlEngineDebugService: Avoid assert when debugging QModelIndex
QModelIndex is not streamable, so returning the input QVariant in valueContents() will result in an assert. We try to detect whether the input QVariant is a know value type and then call the toString() meta-method on it. Otherwise, we fall back to thge old behavior. This works since QModelIndex is exposed to QML wrapped in an internal value type class (at least for the time being). Change-Id: I1a4c61b2bd441f823469dd73b31e86a1192f02e6 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/debugger/qqmlenginedebugservice.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/qml/debugger/qqmlenginedebugservice.cpp b/src/qml/debugger/qqmlenginedebugservice.cpp
index 088f3203d6..a8c1af73cb 100644
--- a/src/qml/debugger/qqmlenginedebugservice.cpp
+++ b/src/qml/debugger/qqmlenginedebugservice.cpp
@@ -207,8 +207,22 @@ QVariant QQmlEngineDebugService::valueContents(QVariant value) const
return contents;
}
- if (QQmlValueTypeFactory::isValueType(userType))
+ if (QQmlValueTypeFactory::isValueType(userType)) {
+ const QMetaObject *mo = QQmlValueTypeFactory::metaObjectForMetaType(userType);
+ if (mo) {
+ int toStringIndex = mo->indexOfMethod("toString");
+ if (toStringIndex != -1) {
+ QMetaMethod mm = mo->method(toStringIndex);
+ QMetaType info(userType);
+ QString s;
+ if (info.flags() & QMetaType::IsGadget
+ && mm.invokeOnGadget(value.data(), Q_RETURN_ARG(QString, s)))
+ return s;
+ }
+ }
+
return value;
+ }
if (QQmlMetaType::isQObject(userType)) {
QObject *o = QQmlMetaType::toQObject(value);