Commit b149ee8d authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Fixed invalid order when inserting new objects.

Done-with: ckamm
Task-number: BAUHAUS-631
parent ce082fe6
......@@ -276,29 +276,33 @@ void QMLRewriter::includeLeadingEmptyLine(int &start) const
UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(UiObjectMemberList *members, const QStringList &propertyOrder)
{
const int objectDefinitionInsertionPoint = propertyOrder.indexOf(QString::null);
UiObjectMemberList *previous = 0;
UiObjectMemberList *lastObjectDef = 0;
UiObjectMemberList *lastNonObjectDef = 0;
for (UiObjectMemberList *iter = members; iter; iter = iter->next) {
UiObjectMember *member = iter->member;
int idx = -1;
if (UiArrayBinding *arrayBinding = cast<UiArrayBinding*>(member))
if (cast<UiObjectDefinition*>(member))
lastObjectDef = iter;
else if (UiArrayBinding *arrayBinding = cast<UiArrayBinding*>(member))
idx = propertyOrder.indexOf(flatten(arrayBinding->qualifiedId));
else if (UiObjectBinding *objectBinding = cast<UiObjectBinding*>(member))
idx = propertyOrder.indexOf(flatten(objectBinding->qualifiedId));
else if (cast<UiObjectDefinition*>(member))
idx = propertyOrder.indexOf(QString::null);
else if (UiScriptBinding *scriptBinding = cast<UiScriptBinding*>(member))
idx = propertyOrder.indexOf(flatten(scriptBinding->qualifiedId));
else if (cast<UiPublicMember*>(member))
idx = propertyOrder.indexOf(QLatin1String("property"));
if (idx > objectDefinitionInsertionPoint)
return iter;
previous = iter;
if (idx < objectDefinitionInsertionPoint)
lastNonObjectDef = iter;
}
return previous;
if (lastObjectDef)
return lastObjectDef;
else
return lastNonObjectDef;
}
UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(UiObjectMemberList *members, const QString &propertyName, const QStringList &propertyOrder)
......
......@@ -663,8 +663,6 @@ void TestCore::testRewriterPreserveOrder()
QCOMPARE(newModelNode.id(), QString("rectangle2"));
}
QSKIP("See BAUHAUS-631", SkipAll);
{
QPlainTextEdit textEdit;
textEdit.setPlainText(qmlString1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment