diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2011-04-20 12:16:03 (GMT) |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2011-04-20 12:16:03 (GMT) |
commit | 5184d55d434296710041812976656ed6825447ec (patch) | |
tree | ad68ae3ba1ef15d6ed2fed74f76b93e5e9fa1e25 | |
parent | e684cfbe8a873040f1e6b0f7fe4bae76a6c1c5de (diff) | |
download | Qt-5184d55d434296710041812976656ed6825447ec.zip Qt-5184d55d434296710041812976656ed6825447ec.tar.gz Qt-5184d55d434296710041812976656ed6825447ec.tar.bz2 |
QDeclarativeDebug: Fix endless loop for property with SCRITABLE false
Trying to read a property marked as non-scriptable results in an
endless loop in QDeclarativePropertyCache::create .
Task-number: QTBUG-18758
Reviewed-by: Aaron Kennedy
-rw-r--r-- | src/declarative/qml/qdeclarativeenginedebug.cpp | 12 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp | 21 |
2 files changed, 27 insertions, 6 deletions
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp index 31fd516..b2a05c3 100644 --- a/src/declarative/qml/qdeclarativeenginedebug.cpp +++ b/src/declarative/qml/qdeclarativeenginedebug.cpp @@ -249,10 +249,16 @@ void QDeclarativeEngineDebugServer::buildObjectDump(QDataStream &message, return; } - message << (object->metaObject()->propertyCount() + fakeProperties.count()); + QList<int> propertyIndexes; + for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) { + if (object->metaObject()->property(ii).isScriptable()) + propertyIndexes << ii; + } + + message << propertyIndexes.size() + fakeProperties.count(); - for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) - message << propertyData(object, ii); + for (int ii = 0; ii < propertyIndexes.size(); ++ii) + message << propertyData(object, propertyIndexes.at(ii)); for (int ii = 0; ii < fakeProperties.count(); ++ii) message << fakeProperties[ii]; diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index d01463e..69f9732 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -66,7 +66,6 @@ Q_DECLARE_METATYPE(QDeclarativeDebugWatch::State) - class tst_QDeclarativeDebug : public QObject { Q_OBJECT @@ -118,6 +117,18 @@ private slots: void setBindingInStates(); }; +class NonScriptProperty : public QObject { + Q_OBJECT + Q_PROPERTY(int nonScriptProp READ nonScriptProp WRITE setNonScriptProp NOTIFY nonScriptPropChanged SCRIPTABLE false) +public: + int nonScriptProp() const { return 0; } + void setNonScriptProp(int) {} +signals: + void nonScriptPropChanged(); +}; +QML_DECLARE_TYPE(NonScriptProperty) + + QDeclarativeDebugObjectReference tst_QDeclarativeDebug::findRootObject(int context, bool recursive) { QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); @@ -282,6 +293,7 @@ void tst_QDeclarativeDebug::compareProperties(const QDeclarativeDebugPropertyRef void tst_QDeclarativeDebug::initTestCase() { qRegisterMetaType<QDeclarativeDebugWatch::State>(); + qmlRegisterType<NonScriptProperty>("Test", 1, 0, "NonScriptPropertyElement"); QTest::ignoreMessage(QtWarningMsg, "Qml debugging is enabled. Only use this in a safe environment!"); QDeclarativeDebugHelper::enableDebugging(); @@ -291,7 +303,8 @@ void tst_QDeclarativeDebug::initTestCase() QList<QByteArray> qml; qml << "import QtQuick 1.0\n" - "Item {" + "import Test 1.0\n" + "Item {" "id: root\n" "width: 10; height: 20; scale: blueRect.scale;" "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }" @@ -307,6 +320,8 @@ void tst_QDeclarativeDebug::initTestCase() "list[0] = blueRect;\n" "varObjList = list;\n" "}\n" + "NonScriptPropertyElement {\n" + "}\n" "}"; // add second component to test multiple root contexts @@ -725,7 +740,7 @@ void tst_QDeclarativeDebug::queryObject() // check source as defined in main() QDeclarativeDebugFileReference source = obj.source(); QCOMPARE(source.url(), QUrl::fromLocalFile("")); - QCOMPARE(source.lineNumber(), 2); + QCOMPARE(source.lineNumber(), 3); QCOMPARE(source.columnNumber(), 1); // generically test all properties, children and childrens' properties |