aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2014-11-06 11:43:19 +0100
committerKai Koehne <kai.koehne@theqtcompany.com>2014-11-07 09:15:01 +0100
commitefa81f8354f70d99e6341ffa5428495b28e68641 (patch)
tree743ef90f9504d7785517170eaa390cb6148e32a2 /src
parenta4877338826381d454dfdae74242a007b3aac9e0 (diff)
Inspector: Do not assert when trying to stream QModelIndex
Some QVariant's like QModelIndex cannot be streamed in a meaningful way: QDataType::save() will return false for them. However, this leads to a qWarning and Q_ASSERT in QVariant::operator<<(). To prevent this we're calling QDataType::save() manually beforehand. We however throw away the result if it succeeds, and still call QVariant::operator<<() to get the benefits of the QDataStream version handling. The alternatives would be to make QVariant::operator<<() not assert, or blacklist all known types with problems manually. Both seem to be difficult though ... Change-Id: I4f5fe6d5a3a076c24fbc73371a4d12d720de53da Task-number: QTBUG-42438 Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/debugger/qqmlenginedebugservice.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/qml/debugger/qqmlenginedebugservice.cpp b/src/qml/debugger/qqmlenginedebugservice.cpp
index cb533a0459..088f3203d6 100644
--- a/src/qml/debugger/qqmlenginedebugservice.cpp
+++ b/src/qml/debugger/qqmlenginedebugservice.cpp
@@ -96,8 +96,16 @@ QDataStream &operator>>(QDataStream &ds,
QDataStream &operator<<(QDataStream &ds,
const QQmlEngineDebugService::QQmlObjectProperty &data)
{
- ds << (int)data.type << data.name << data.value << data.valueTypeName
- << data.binding << data.hasNotifySignal;
+ ds << (int)data.type << data.name;
+ // check first whether the data can be saved
+ // (otherwise we assert in QVariant::operator<<)
+ QByteArray buffer;
+ QDataStream fakeStream(&buffer, QIODevice::WriteOnly);
+ if (QMetaType::save(fakeStream, data.value.type(), data.value.constData()))
+ ds << data.value;
+ else
+ ds << QVariant();
+ ds << data.valueTypeName << data.binding << data.hasNotifySignal;
return ds;
}