Inspector: Do not assert when trying to stream QModelIndex
authorKai Koehne <kai.koehne@digia.com>
Thu, 6 Nov 2014 10:43:19 +0000 (11:43 +0100)
committerKai Koehne <kai.koehne@theqtcompany.com>
Fri, 7 Nov 2014 08:15:01 +0000 (09:15 +0100)
commitefa81f8354f70d99e6341ffa5428495b28e68641
tree743ef90f9504d7785517170eaa390cb6148e32a2
parenta4877338826381d454dfdae74242a007b3aac9e0
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>
src/qml/debugger/qqmlenginedebugservice.cpp
tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp