aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/debugger/qqmlenginedebugservice
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 /tests/auto/qml/debugger/qqmlenginedebugservice
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 'tests/auto/qml/debugger/qqmlenginedebugservice')
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
index 5bbbe8e1e9..7c931928d4 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
@@ -36,6 +36,7 @@
#include <QHostAddress>
#include <QDebug>
#include <QThread>
+#include <QModelIndex>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcontext.h>
@@ -73,6 +74,16 @@ signals:
};
QML_DECLARE_TYPE(NonScriptProperty)
+class CustomTypes : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QModelIndex modelIndex READ modelIndex)
+public:
+ CustomTypes(QObject *parent = 0) : QObject(parent) {}
+
+ QModelIndex modelIndex() { return QModelIndex(); }
+};
+
class tst_QQmlEngineDebugService : public QObject
{
Q_OBJECT
@@ -125,6 +136,7 @@ private slots:
void setBindingInStates();
void regression_QTCREATORBUG_7451();
+ void queryObjectWithNonStreamableTypes();
};
QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
@@ -314,6 +326,12 @@ void tst_QQmlEngineDebugService::initTestCase()
"}\n"
;
+ // test non-streamable properties
+ qmlRegisterType<CustomTypes>("Backend", 1, 0, "CustomTypes");
+ qml << "import Backend 1.0\n"
+ "CustomTypes {}"
+ ;
+
for (int i=0; i<qml.count(); i++) {
QQmlComponent component(m_engine);
component.setData(qml[i], QUrl::fromLocalFile(""));
@@ -620,7 +638,7 @@ void tst_QQmlEngineDebugService::queryRootContexts()
// root context query sends only root object data - it doesn't fill in
// the children or property info
QCOMPARE(context.objects.count(), 0);
- QCOMPARE(context.contexts.count(), 5);
+ QCOMPARE(context.contexts.count(), 6);
QVERIFY(context.contexts[0].debugId >= 0);
QCOMPARE(context.contexts[0].name, QString("tst_QQmlDebug_childContext"));
}
@@ -819,6 +837,26 @@ void tst_QQmlEngineDebugService::regression_QTCREATORBUG_7451()
}
}
+void tst_QQmlEngineDebugService::queryObjectWithNonStreamableTypes()
+{
+ bool success;
+
+ QmlDebugObjectReference rootObject = findRootObject(4, true);
+
+ QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0);
+ unconnected->queryObject(rootObject, &success);
+ QVERIFY(!success);
+ delete unconnected;
+
+ m_dbg->queryObject(rootObject, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+
+ QmlDebugObjectReference obj = m_dbg->object();
+
+ QCOMPARE(findProperty(obj.properties, "modelIndex").value, QVariant());
+}
+
void tst_QQmlEngineDebugService::queryExpressionResult()
{