diff --git a/src/plugins/qmldesigner/core/filemanager/addobjectvisitor.cpp b/src/plugins/qmldesigner/core/filemanager/addobjectvisitor.cpp
index 7e56a004211d8303a3dc803fa7bfe1eec07f660f..ce00cbf23e12e155662a6f3f7f2f9c61fece56f4 100644
--- a/src/plugins/qmldesigner/core/filemanager/addobjectvisitor.cpp
+++ b/src/plugins/qmldesigner/core/filemanager/addobjectvisitor.cpp
@@ -72,7 +72,7 @@ bool AddObjectVisitor::visit(QmlJS::AST::UiObjectDefinition *ast)
 
 void AddObjectVisitor::insertInto(QmlJS::AST::UiObjectInitializer *ast)
 {
-    UiObjectMemberList *insertAfter = searchMemberToInsertAfter(ast->members, QString(), m_propertyOrder);
+    UiObjectMemberList *insertAfter = searchMemberToInsertAfter(ast->members, m_propertyOrder);
 
     int insertionPoint;
     int depth;
diff --git a/src/plugins/qmldesigner/core/filemanager/moveobjectvisitor.cpp b/src/plugins/qmldesigner/core/filemanager/moveobjectvisitor.cpp
index 85dee276662e8e828bddcdfa27ab3d0141d768d6..0874bc46485b861028b4b5e0fbca46a53d3b4ad4 100644
--- a/src/plugins/qmldesigner/core/filemanager/moveobjectvisitor.cpp
+++ b/src/plugins/qmldesigner/core/filemanager/moveobjectvisitor.cpp
@@ -87,7 +87,7 @@ private:
     {
         if (targetPropertyName.isEmpty()) {
             // insert as UiObjectDefinition:
-            UiObjectMemberList *insertAfter = searchMemberToInsertAfter(ast->members, QString(), propertyOrder);
+            UiObjectMemberList *insertAfter = searchMemberToInsertAfter(ast->members, propertyOrder);
 
             if (insertAfter && insertAfter->member) {
                 moveInfo.destination = insertAfter->member->lastSourceLocation().end();
diff --git a/src/plugins/qmldesigner/core/filemanager/qmlrewriter.cpp b/src/plugins/qmldesigner/core/filemanager/qmlrewriter.cpp
index c06aa7b27ad756b8f3f77d50adda4d73e355ba16..59813ac8a552a3248e77a34cfd56fba05437f5de 100644
--- a/src/plugins/qmldesigner/core/filemanager/qmlrewriter.cpp
+++ b/src/plugins/qmldesigner/core/filemanager/qmlrewriter.cpp
@@ -270,6 +270,34 @@ void QMLRewriter::includeLeadingEmptyLine(int &start) const
     start = prevBlock.position();
 }
 
+UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(UiObjectMemberList *members, const QStringList &propertyOrder)
+{
+    const int objectDefinitionInsertionPoint = propertyOrder.indexOf(QString::null);
+    UiObjectMemberList *previous = 0;
+    for (UiObjectMemberList *iter = members; iter; iter = iter->next) {
+        UiObjectMember *member = iter->member;
+        int idx = -1;
+
+        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;
+    }
+
+    return previous;
+}
+
 UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(UiObjectMemberList *members, const QString &propertyName, const QStringList &propertyOrder)
 {
     if (!members)
@@ -298,9 +326,9 @@ UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(UiObjectMemberList *m
     if (idx == -1)
         idx = propertyOrder.size() - 1;
 
-    for (; idx >= 0; --idx) {
-        const QString prop = propertyOrder.at(idx);
-        UiObjectMemberList *candidate = orderedMembers[prop];
+    for (; idx > 0; --idx) {
+        const QString prop = propertyOrder.at(idx - 1);
+        UiObjectMemberList *candidate = orderedMembers.value(prop, 0);
         if (candidate != 0)
             return candidate;
     }
diff --git a/src/plugins/qmldesigner/core/filemanager/qmlrewriter.h b/src/plugins/qmldesigner/core/filemanager/qmlrewriter.h
index 225c2a846fc4940743819b1bfea0b3b0b9b8734b..d6e7279ae0285d030742f97cc4888f3b6409b17d 100644
--- a/src/plugins/qmldesigner/core/filemanager/qmlrewriter.h
+++ b/src/plugins/qmldesigner/core/filemanager/qmlrewriter.h
@@ -79,6 +79,7 @@ protected:
     bool includeSurroundingWhitespace(int &start, int &end) const;
     void includeLeadingEmptyLine(int &start) const;
 
+    static QmlJS::AST::UiObjectMemberList *searchMemberToInsertAfter(QmlJS::AST::UiObjectMemberList *members, const QStringList &propertyOrder);
     static QmlJS::AST::UiObjectMemberList *searchMemberToInsertAfter(QmlJS::AST::UiObjectMemberList *members, const QString &propertyName, const QStringList &propertyOrder);
 
 protected: