diff --git a/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp b/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp index ebd5f88a67baea66fa21c8984b9e13bc6764bee4..5af8c0a397288307c405fbf2c109074b54ea7a75 100644 --- a/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp +++ b/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp @@ -421,16 +421,28 @@ void QDeclarativeViewObserverPrivate::_q_createQmlObject(const QString &qml, QOb QObject *newObject = component.create(parentContext); if (newObject) { newObject->setParent(parent); - QDeclarativeItem *parentItem = qobject_cast<QDeclarativeItem*>(parent); - QDeclarativeItem *newItem = qobject_cast<QDeclarativeItem*>(newObject); - if (parentItem && newItem) - newItem->setParentItem(parentItem); - else { + do { + QDeclarativeItem *parentItem = qobject_cast<QDeclarativeItem*>(parent); + QDeclarativeItem *newItem = qobject_cast<QDeclarativeItem*>(newObject); + if (parentItem && newItem) { + newItem->setParentItem(parentItem); + break; + } + QDeclarativeState *parentState = qobject_cast<QDeclarativeState*>(parent); QDeclarativeStateOperation *newPropertyChanges = qobject_cast<QDeclarativeStateOperation *>(newObject); - if (parentState && newPropertyChanges) + if (parentState && newPropertyChanges) { (*parentState) << newPropertyChanges; - } + break; + } + + QDeclarativeState *newState = qobject_cast<QDeclarativeState*>(newObject); + if (parentItem && newState) { + QDeclarativeListReference statesList(parentItem, "states"); + statesList.append(newObject); + break; + } + } while (false); } } diff --git a/src/libs/qmljs/qmljsdelta.cpp b/src/libs/qmljs/qmljsdelta.cpp index a85b1e5250de32cec8e455cd4946d63e2bf95546..9ccffa49d9f585ed146657f469ea7cf59d3a82bf 100644 --- a/src/libs/qmljs/qmljsdelta.cpp +++ b/src/libs/qmljs/qmljsdelta.cpp @@ -350,12 +350,31 @@ void Delta::insert(UiObjectMember *member, UiObjectMember *parentMember, const Q if (!member || !parentMember) return; + unsigned begin, end, startColumn, startLine; + bool accepted = false; + // create new objects if (UiObjectDefinition* uiObjectDef = cast<UiObjectDefinition *>(member)) { - unsigned begin = uiObjectDef->firstSourceLocation().begin(); - unsigned end = uiObjectDef->lastSourceLocation().end(); - QString qmlText = QString(uiObjectDef->firstSourceLocation().startColumn - 1, QLatin1Char(' ')); + begin = uiObjectDef->firstSourceLocation().begin(); + end = uiObjectDef->lastSourceLocation().end(); + startColumn = uiObjectDef->firstSourceLocation().startColumn; + startLine = uiObjectDef->firstSourceLocation().startLine; + accepted = true; + } + + if (UiObjectBinding* uiObjectBind = cast<UiObjectBinding *>(member)) { + SourceLocation definitionLocation = uiObjectBind->qualifiedTypeNameId->identifierToken; + begin = definitionLocation.begin(); + end = uiObjectBind->lastSourceLocation().end(); + startColumn = definitionLocation.startColumn; + startLine = definitionLocation.startLine; + accepted = true; + } + + if (accepted) { + QString qmlText = QString(startColumn - 1, QLatin1Char(' ')); qmlText += doc->source().midRef(begin, end - begin); + QStringList importList; for (UiImportList *it = doc->qmlProgram()->imports; it; it = it->next) { if (!it->import) @@ -368,7 +387,7 @@ void Delta::insert(UiObjectMember *member, UiObjectMember *parentMember, const Q // encode editorRevision, lineNumber in URL. See ClientProxy::buildDebugIdHashRecursive QString filename = QLatin1String("file://") + doc->fileName() + QLatin1Char('_') + QString::number(doc->editorRevision()) - + QLatin1Char(':') + QString::number(uiObjectDef->firstSourceLocation().startLine-importList.count()); + + QLatin1Char(':') + QString::number(startLine-importList.count()); foreach(DebugId debugId, debugReferences) { if (debugId != -1) { createObject(qmlText, debugId, importList, filename); @@ -484,11 +503,14 @@ Delta::DebugIdMap Delta::operator()(const Document::Ptr &doc1, const Document::P if (!M.way2.contains(y)) { UiObjectMember* parent = parents2.parent.value(y); - if (!M.way2.contains(parent)) - continue; - if (debug) - qDebug () << "Delta::operator(): insert " << label(y, doc2) << " to " << label(parent, doc2); - insert(y, parent, newDebuggIds.value(parent), doc2); + if ( parent->kind == QmlJS::AST::Node::Kind_UiArrayBinding ) + parent = parents2.parent.value(parent); + + if (M.way2.contains(parent) && newDebuggIds.value(parent).count() > 0) { + if (debug) + qDebug () << "Delta::operator(): insert " << label(y, doc2) << " to " << label(parent, doc2); + insert(y, parent, newDebuggIds.value(parent), doc2); + } continue; } UiObjectMember *x = M.way2[y]; @@ -500,6 +522,8 @@ Delta::DebugIdMap Delta::operator()(const Document::Ptr &doc1, const Document::P updateIds = debugIds[x]; newDebuggIds[y] = updateIds; } + if (debug) + qDebug () << "Delta::operator(): update " << label(x,doc1); update(x, doc1, y, doc2, updateIds); } //qDebug() << "Delta::operator(): match "<< label(x, doc1) << "with parent " << label(parents1.parent.value(x), doc1)