diff options
3 files changed, 26 insertions, 2 deletions
diff --git a/src/declarative/debugger/qdeclarativeenginedebug.cpp b/src/declarative/debugger/qdeclarativeenginedebug.cpp index 3232eeab..2eabc0ba 100644 --- a/src/declarative/debugger/qdeclarativeenginedebug.cpp +++ b/src/declarative/debugger/qdeclarativeenginedebug.cpp @@ -932,6 +932,20 @@ QList<QDeclarativeDebugObjectReference> QDeclarativeDebugObjectReference::childr return m_children; } +QDeclarativeDebugObjectReference QDeclarativeDebugObjectReference::findChildByClassName(const QString &className, QDeclarativeDebugObjectReference after) const +{ + foreach (const QDeclarativeDebugObjectReference &child, m_children) + if (after.debugId() != -1) { + if (child.debugId() == after.debugId()) + after = QDeclarativeDebugObjectReference(); + } else { + if (child.className() == className) + return child; + } + + return QDeclarativeDebugObjectReference(); +} + QDeclarativeDebugContextReference::QDeclarativeDebugContextReference() : m_debugId(-1) { diff --git a/src/declarative/debugger/qdeclarativeenginedebug_p.h b/src/declarative/debugger/qdeclarativeenginedebug_p.h index 9c1246ac..c1e37110 100644 --- a/src/declarative/debugger/qdeclarativeenginedebug_p.h +++ b/src/declarative/debugger/qdeclarativeenginedebug_p.h @@ -254,6 +254,9 @@ public: QList<QDeclarativeDebugPropertyReference> properties() const; QList<QDeclarativeDebugObjectReference> children() const; + QDeclarativeDebugObjectReference findChildByClassName(const QString &className, + QDeclarativeDebugObjectReference after = QDeclarativeDebugObjectReference()) const; + private: friend class QDeclarativeEngineDebugPrivate; int m_debugId; diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index c77d6bb8..58434442 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -1167,7 +1167,8 @@ void tst_QDeclarativeDebug::queryObjectTree() // check state - QDeclarativeDebugObjectReference state = obj.children()[0]; + QDeclarativeDebugObjectReference state = obj.findChildByClassName(QString("State")); + QVERIFY(state.debugId() != -1); QCOMPARE(state.className(), QString("State")); QVERIFY(state.children().count() > 0); @@ -1180,10 +1181,13 @@ void tst_QDeclarativeDebug::queryObjectTree() QDeclarativeDebugObjectReference targetReference = qvariant_cast<QDeclarativeDebugObjectReference>(propertyChangeTarget.value()); QVERIFY(targetReference.debugId() != -1); + QDeclarativeDebugObjectReference nextState = obj.findChildByClassName(QString("State"), state); + QVERIFY(nextState.debugId() == -1); // check transition - QDeclarativeDebugObjectReference transition = obj.children()[1]; + QDeclarativeDebugObjectReference transition = obj.findChildByClassName(QString("Transition")); + QVERIFY(transition.debugId() != -1); QCOMPARE(transition.className(), QString("Transition")); QCOMPARE(findProperty(transition.properties(),"from").value().toString(), QString("*")); QCOMPARE(findProperty(transition.properties(),"to").value(), findProperty(state.properties(),"name").value()); @@ -1200,6 +1204,9 @@ void tst_QDeclarativeDebug::queryObjectTree() QCOMPARE(findProperty(animation.properties(),"property").value().toString(), QString("width")); QCOMPARE(findProperty(animation.properties(),"duration").value().toInt(), 100); + + QDeclarativeDebugObjectReference nextTransition = obj.findChildByClassName(QString("Transition"), transition); + QVERIFY(nextTransition.debugId() == -1); } int main(int argc, char *argv[]) |