+++ /dev/null
-diff --git a/src/plugins/qmldesigner/components/formeditor/dragtool.cpp b/src/plugins/qmldesigner/components/formeditor/dragtool.cpp
-index ee55ff4..30a3948 100644
---- a/src/plugins/qmldesigner/components/formeditor/dragtool.cpp
-+++ b/src/plugins/qmldesigner/components/formeditor/dragtool.cpp
-@@ -37,10 +37,12 @@
- #include <metainfo.h>
-
- #include "resizehandleitem.h"
-+#include <rewritingexception.h>
-
- #include <QApplication>
- #include <QGraphicsSceneMouseEvent>
- #include <QtDebug>
-+#include <QMessageBox>
-
- namespace QmlDesigner {
-
-@@ -143,7 +145,7 @@ void DragTool::createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, QmlIt
- m_dragNode = view()->createQmlItemNode(itemLibraryEntry, pos, parentNode);
-
- Q_ASSERT(m_dragNode.modelNode().isValid());
-- Q_ASSERT(m_dragNode.isValid());
-+ //Q_ASSERT(m_dragNode.isValid());
-
- QList<QmlItemNode> nodeList;
- nodeList.append(m_dragNode);
-@@ -205,7 +207,11 @@ void DragTool::dropEvent(QGraphicsSceneDragDropEvent * event)
- event->accept();
- end(event->scenePos());
- //Q_ASSERT(m_token.isValid());
-- m_rewriterTransaction.commit();
-+ try {
-+ m_rewriterTransaction.commit();
-+ } catch (RewritingException &e) {
-+ QMessageBox::warning(0, "Error", e.description());
-+ }
- m_dragNode = ModelNode();
- view()->changeToSelectionTool();
- }
-@@ -230,7 +236,11 @@ void DragTool::dragLeaveEvent(QGraphicsSceneDragDropEvent * event)
- if (m_dragNode.isValid())
- m_dragNode.destroy();
- end(event->scenePos());
-- m_rewriterTransaction.commit();
-+ try {
-+ m_rewriterTransaction.commit();
-+ } catch (RewritingException &e) {
-+ QMessageBox::warning(0, "Error", e.description());
-+ }
- QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::show();
- QList<QmlItemNode> nodeList;
- view()->setSelectedQmlItemNodes(nodeList);
-diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp
-index 3488be9..f8a18ea 100644
---- a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp
-+++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp
-@@ -116,8 +116,9 @@ void FormEditorView::setupFormEditorItemTree(const QmlItemNode &qmlItemNode)
- {
- m_scene->addFormEditorItem(qmlItemNode);
-
-- foreach (const QmlItemNode &nextNode, qmlItemNode.children()) //TODO instance children
-- setupFormEditorItemTree(nextNode);
-+ foreach (const QmlObjectNode &nextNode, qmlItemNode.allDirectSubNodes()) //TODO instance children
-+ if (QmlItemNode(nextNode).isValid())
-+ setupFormEditorItemTree(nextNode.toQmlItemNode());
- }
-
- void FormEditorView::nodeCreated(const ModelNode &createdNode)
-diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
-index f68dfa0..71f8124 100644
---- a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
-+++ b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
-@@ -47,6 +47,7 @@
- #include <componentaction.h>
- #include <qmlobjectnode.h>
- #include <rewriterview.h>
-+#include <rewritingexception.h>
- #include <nodelistproperty.h>
- #include <toolbox.h>
-
-@@ -462,6 +463,8 @@ void DesignDocumentController::copySelected()
- QScopedPointer<Model> model(Model::create("Qt/Rectangle"));
- model->setMetaInfo(m_d->model->metaInfo());
- model->setFileUrl(m_d->model->fileUrl());
-+ foreach (const Import &import, m_d->model->imports())
-+ model->addImport(import);
-
- Q_ASSERT(model);
-
-@@ -557,6 +560,8 @@ void DesignDocumentController::paste()
- QScopedPointer<Model> model(Model::create("empty"));
- model->setMetaInfo(m_d->model->metaInfo());
- model->setFileUrl(m_d->model->fileUrl());
-+ foreach (const Import &import, m_d->model->imports())
-+ model->addImport(import);
- Q_ASSERT(model);
-
- if (!m_d->model)
-@@ -601,48 +606,56 @@ void DesignDocumentController::paste()
-
- QList<ModelNode> pastedNodeList;
-
-- RewriterTransaction transaction(m_d->formEditorView.data());
-+ try {
-+ RewriterTransaction transaction(m_d->formEditorView.data());
-
-- int offset = double(qrand()) / RAND_MAX * 20 - 10;
-+ int offset = double(qrand()) / RAND_MAX * 20 - 10;
-
-- foreach (const ModelNode &node, selectedNodes) {
-- QString defaultProperty(targetNode.metaInfo().defaultProperty());
-- ModelNode pastedNode(view.insertModel(node));
-- pastedNodeList.append(pastedNode);
-- scatterItem(pastedNode, targetNode, offset);
-- targetNode.nodeListProperty(defaultProperty).reparentHere(pastedNode);
-- }
-+ foreach (const ModelNode &node, selectedNodes) {
-+ QString defaultProperty(targetNode.metaInfo().defaultProperty());
-+ ModelNode pastedNode(view.insertModel(node));
-+ pastedNodeList.append(pastedNode);
-+ scatterItem(pastedNode, targetNode, offset);
-+ targetNode.nodeListProperty(defaultProperty).reparentHere(pastedNode);
-+ }
-
-- view.setSelectedModelNodes(pastedNodeList);
-+ view.setSelectedModelNodes(pastedNodeList);
-+ } catch (RewritingException &e) {
-+ qWarning() << e.description(); //silent error
-+ }
- } else {
-- RewriterTransaction transaction(m_d->formEditorView.data());
-+ try {
-+ RewriterTransaction transaction(m_d->formEditorView.data());
-
-- model->detachView(&view);
-- m_d->model->attachView(&view);
-- ModelNode pastedNode(view.insertModel(rootNode));
-- ModelNode targetNode;
-+ model->detachView(&view);
-+ m_d->model->attachView(&view);
-+ ModelNode pastedNode(view.insertModel(rootNode));
-+ ModelNode targetNode;
-
-- if (!view.selectedModelNodes().isEmpty())
-- targetNode = view.selectedModelNodes().first();
-+ if (!view.selectedModelNodes().isEmpty())
-+ targetNode = view.selectedModelNodes().first();
-
-- if (!targetNode.isValid())
-- targetNode = view.rootModelNode();
-+ if (!targetNode.isValid())
-+ targetNode = view.rootModelNode();
-
-- if (targetNode.parentProperty().isValid() &&
-- (pastedNode.simplifiedTypeName() == targetNode.simplifiedTypeName()) &&
-- (pastedNode.variantProperty("width").value() == targetNode.variantProperty("width").value()) &&
-- (pastedNode.variantProperty("height").value() == targetNode.variantProperty("height").value()))
-+ if (targetNode.parentProperty().isValid() &&
-+ (pastedNode.simplifiedTypeName() == targetNode.simplifiedTypeName()) &&
-+ (pastedNode.variantProperty("width").value() == targetNode.variantProperty("width").value()) &&
-+ (pastedNode.variantProperty("height").value() == targetNode.variantProperty("height").value()))
-
-- targetNode = targetNode.parentProperty().parentModelNode();
-+ targetNode = targetNode.parentProperty().parentModelNode();
-
-- QString defaultProperty(targetNode.metaInfo().defaultProperty());
-+ QString defaultProperty(targetNode.metaInfo().defaultProperty());
-
-- scatterItem(pastedNode, targetNode);
-- if (targetNode.nodeListProperty(defaultProperty).isValid()) {
-- targetNode.nodeListProperty(defaultProperty).reparentHere(pastedNode);
-- }
-+ scatterItem(pastedNode, targetNode);
-+ if (targetNode.nodeListProperty(defaultProperty).isValid()) {
-+ targetNode.nodeListProperty(defaultProperty).reparentHere(pastedNode);
-+ }
-
-- view.setSelectedModelNodes(QList<ModelNode>() << pastedNode);
-+ view.setSelectedModelNodes(QList<ModelNode>() << pastedNode);
-+ } catch (RewritingException &e) {
-+ qWarning() << e.description(); //silent error
-+ }
- }
- }
-
-diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp
-index dc5244f..5d5890d 100644
---- a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp
-+++ b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp
-@@ -130,7 +130,12 @@ void DesignDocumentControllerView::fromText(QString text)
- inputModel->setMetaInfo(model()->metaInfo());
- inputModel->setFileUrl(model()->fileUrl());
- QPlainTextEdit textEdit;
-- QString imports("import Qt 4.7;\n");
-+ QString imports;//("import Qt 4.7;\n");
-+ qDebug() << imports;
-+ qDebug() << model()->metaInfo().hasNodeMetaInfo("Button");
-+ foreach (Import import, model()->imports())
-+ imports += import.toString() + ";\n";
-+ qDebug() << imports;
- textEdit.setPlainText(imports + text);
- NotIndentingTextEditModifier modifier(&textEdit);
-
-diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
-index ec66ff7..df08b21 100644
---- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
-+++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
-@@ -37,6 +37,7 @@
- #include <qgraphicswidget.h>
- #include <abstractview.h>
- #include <invalididexception.h>
-+#include <rewritingexception.h>
-
- #include <QMimeData>
- #include <QMessageBox>
-@@ -470,49 +471,55 @@ void NavigatorTreeModel::removeSubTree(const ModelNode &node)
-
- void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty parentProperty, const QList<ModelNode> &modelNodes, int targetIndex)
- {
-- QString propertyQmlType = qmlTypeInQtContainer(parentProperty.metaInfo().type());
--
-- RewriterTransaction transaction = m_view->beginRewriterTransaction();
-- foreach (const ModelNode &node, modelNodes) {
-- if (!node.isValid())
-- continue;
--
-- if (node != parentProperty.parentModelNode() &&
-- !node.isAncestorOf(parentProperty.parentModelNode()) &&
-- node.metaInfo().isSubclassOf(propertyQmlType, -1, -1)) {
--
-- if (node.parentProperty() != parentProperty) {
-+ try {
-+ QString propertyQmlType = qmlTypeInQtContainer(parentProperty.metaInfo().type());
-+
-+ RewriterTransaction transaction = m_view->beginRewriterTransaction();
-+ foreach (const ModelNode &node, modelNodes) {
-+ if (!node.isValid())
-+ continue;
-+
-+ if (node != parentProperty.parentModelNode() &&
-+ !node.isAncestorOf(parentProperty.parentModelNode()) &&
-+ (node.metaInfo().isSubclassOf(propertyQmlType, -1, -1) || propertyQmlType == "alias")) {
-+ //### todo: allowing alias is just a heuristic
-+ //once the MetaInfo is part of instances we can do this right
-+
-+ if (node.parentProperty() != parentProperty) {
-+
-+ if (parentProperty.isNodeProperty()) {
-+ ModelNode propertyNode = parentProperty.toNodeProperty().modelNode();
-+ // Destruction of ancestors is not allowed
-+ if (propertyNode.isAncestorOf(node)) {
-+ continue;
-+ }
-+ if (propertyNode.isValid()) {
-+ QApplication::setOverrideCursor(Qt::ArrowCursor);
-+ if (QMessageBox::warning(0, tr("Warning"), tr("Reparenting the component %1 here will cause the component %2 to be deleted. Do you want to proceed?").arg(node.id(), propertyNode.id()), QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) {
-+ QApplication::restoreOverrideCursor();
-+ continue;
-+ }
-+ QApplication::restoreOverrideCursor();
-+ propertyNode.destroy();
-+ }
-+ }
-
-- if (parentProperty.isNodeProperty()) {
-- ModelNode propertyNode = parentProperty.toNodeProperty().modelNode();
-- // Destruction of ancestors is not allowed
-- if (propertyNode.isAncestorOf(node)) {
-- continue;
-+ parentProperty.reparentHere(node);
- }
-- if (propertyNode.isValid()) {
-- QApplication::setOverrideCursor(Qt::ArrowCursor);
-- if (QMessageBox::warning(0, tr("Warning"), tr("Reparenting the component %1 here will cause the component %2 to be deleted. Do you want to proceed?").arg(node.id(), propertyNode.id()), QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) {
-- QApplication::restoreOverrideCursor();
-- continue;
-+
-+ if (parentProperty.isNodeListProperty()) {
-+ int index = parentProperty.toNodeListProperty().toModelNodeList().indexOf(node);
-+ if (index < targetIndex) { // item is first removed from oldIndex, then inserted at new index
-+ --targetIndex;
-+ }
-+ if (index != targetIndex) {
-+ parentProperty.toNodeListProperty().slide(index, targetIndex);
- }
-- QApplication::restoreOverrideCursor();
-- propertyNode.destroy();
- }
-- }
--
-- parentProperty.reparentHere(node);
-- }
--
-- if (parentProperty.isNodeListProperty()) {
-- int index = parentProperty.toNodeListProperty().toModelNodeList().indexOf(node);
-- if (index < targetIndex) { // item is first removed from oldIndex, then inserted at new index
-- --targetIndex;
-- }
-- if (index != targetIndex) {
-- parentProperty.toNodeListProperty().slide(index, targetIndex);
-- }
- }
- }
-+ } catch (RewritingException &e) { //better safe than sorry! There always might be cases where we fail
-+ QMessageBox::warning(0, "Error", e.description());
- }
- }
-
-diff --git a/src/plugins/qmldesigner/designercore/include/metainfo.h b/src/plugins/qmldesigner/designercore/include/metainfo.h
-index 2d4af4d..b09d569 100644
---- a/src/plugins/qmldesigner/designercore/include/metainfo.h
-+++ b/src/plugins/qmldesigner/designercore/include/metainfo.h
-@@ -84,6 +84,7 @@ public:
-
- QString fromQtTypes(const QString &type) const;
-
-+ void inheritFrom(MetaInfo &other);
-
- public:
- static MetaInfo global();
-diff --git a/src/plugins/qmldesigner/designercore/include/nodeinstance.h b/src/plugins/qmldesigner/designercore/include/nodeinstance.h
-index c2fce99..12aa17e 100644
---- a/src/plugins/qmldesigner/designercore/include/nodeinstance.h
-+++ b/src/plugins/qmldesigner/designercore/include/nodeinstance.h
-@@ -59,6 +59,7 @@ namespace Internal {
- class ObjectNodeInstance;
- class QmlGraphicsItemNodeInstance;
- class QmlPropertyChangesNodeInstance;
-+ class GraphicsObjectNodeInstance;
- class QmlStateNodeInstance;
- }
-
-@@ -72,6 +73,7 @@ class CORESHARED_EXPORT NodeInstance
- friend CORESHARED_EXPORT bool operator==(const NodeInstance &first, const NodeInstance &second);
- friend CORESHARED_EXPORT class NodeMetaInfo;
- friend class QmlDesigner::Internal::QmlGraphicsItemNodeInstance;
-+ friend class QmlDesigner::Internal::GraphicsObjectNodeInstance;
- friend class QmlDesigner::Internal::ObjectNodeInstance;
- friend class QmlDesigner::Internal::QmlPropertyChangesNodeInstance;
- friend class QmlDesigner::Internal::QmlStateNodeInstance;
-diff --git a/src/plugins/qmldesigner/designercore/instances/graphicsobjectnodeinstance.cpp b/src/plugins/qmldesigner/designercore/instances/graphicsobjectnodeinstance.cpp
-index 926d446..d658415 100644
---- a/src/plugins/qmldesigner/designercore/instances/graphicsobjectnodeinstance.cpp
-+++ b/src/plugins/qmldesigner/designercore/instances/graphicsobjectnodeinstance.cpp
-@@ -70,8 +70,10 @@ QSizeF GraphicsObjectNodeInstance::size() const
-
- QTransform GraphicsObjectNodeInstance::transform() const
- {
-- if (graphicsObject()->parentItem())
-- return graphicsObject()->itemTransform(graphicsObject()->parentItem());
-+ NodeInstance nodeInstanceParent = nodeInstanceView()->instanceForNode(modelNode()).parent();
-+ QGraphicsObject *graphicsObjectParent = qobject_cast<QGraphicsObject*>(nodeInstanceParent.internalObject());
-+ if (graphicsObjectParent)
-+ return graphicsObject()->itemTransform(graphicsObjectParent);
- else
- return sceneTransform();
- }
-@@ -163,6 +165,11 @@ void initOption(QGraphicsItem *item, QStyleOptionGraphicsItem *option, const QTr
-
- void GraphicsObjectNodeInstance::paintRecursively(QGraphicsItem *graphicsItem, QPainter *painter) const
- {
-+ if (QGraphicsObject *graphicsObject = graphicsItem->toGraphicsObject()) {
-+ if (nodeInstanceView()->hasInstanceForObject(graphicsObject))
-+ return; //we already keep track of this object elsewhere
-+ }
-+
- if (graphicsItem->isVisible()) {
- painter->save();
- painter->setTransform(graphicsItem->itemTransform(graphicsItem->parentItem()), true);
-diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp
-index d331d9c..28acccf 100644
---- a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp
-+++ b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp
-@@ -261,7 +261,21 @@ void NodeInstance::reparent(const NodeInstance &oldParentInstance, const QString
- */
- NodeInstance NodeInstance::parent() const
- {
-- return m_nodeInstance->nodeInstanceView()->instanceForObject(m_nodeInstance->parent());
-+ QObject *parent = m_nodeInstance->parent();
-+ //Maybe the object has been reparented inside a component and we
-+ //do not keep track of the parent?
-+ //In this case we iterate until we find a parent we keep track of,
-+ //parent() gets 0
-+ while (!m_nodeInstance->nodeInstanceView()->hasInstanceForObject(parent)) {
-+ if (!parent) //this should not happen! warning?
-+ return m_nodeInstance->nodeInstanceView()->instanceForObject(parent);
-+ if (QGraphicsObject *graphicsObject = qobject_cast<QGraphicsObject*>(parent))
-+ parent = graphicsObject->parentItem()->toGraphicsObject();
-+ else
-+ parent = parent->parent();
-+ }
-+ m_nodeInstance->nodeInstanceView()->instanceForObject(m_nodeInstance->parent());
-+ return m_nodeInstance->nodeInstanceView()->instanceForObject(parent);
- }
-
- bool NodeInstance::hasParent() const
-diff --git a/src/plugins/qmldesigner/designercore/instances/qmlgraphicsitemnodeinstance.cpp b/src/plugins/qmldesigner/designercore/instances/qmlgraphicsitemnodeinstance.cpp
-index 121b6e0..707592b 100644
---- a/src/plugins/qmldesigner/designercore/instances/qmlgraphicsitemnodeinstance.cpp
-+++ b/src/plugins/qmldesigner/designercore/instances/qmlgraphicsitemnodeinstance.cpp
-@@ -121,13 +121,15 @@ QSizeF QmlGraphicsItemNodeInstance::size() const
- if (modelNode().isRootNode()) {
- if (!m_hasWidth) {
- qmlGraphicsItem()->blockSignals(true);
-- qmlGraphicsItem()->setWidth(100.);
-+ if (qmlGraphicsItem()->width() < 10.)
-+ qmlGraphicsItem()->setWidth(100.);
- qmlGraphicsItem()->blockSignals(false);
- }
-
- if (!m_hasHeight) {
- qmlGraphicsItem()->blockSignals(true);
-- qmlGraphicsItem()->setHeight(100.);
-+ if (qmlGraphicsItem()->height() < 10.)
-+ qmlGraphicsItem()->setHeight(100.);
- qmlGraphicsItem()->blockSignals(false);
- }
- }
-@@ -163,13 +165,15 @@ QRectF QmlGraphicsItemNodeInstance::boundingRect() const
- if (modelNode().isRootNode()) {
- if (!m_hasWidth) {
- qmlGraphicsItem()->blockSignals(true);
-- qmlGraphicsItem()->setWidth(100.);
-+ if (qmlGraphicsItem()->width() < 10.)
-+ qmlGraphicsItem()->setWidth(100.);
- qmlGraphicsItem()->blockSignals(false);
- }
-
- if (!m_hasHeight) {
- qmlGraphicsItem()->blockSignals(true);
-- qmlGraphicsItem()->setHeight(100.);
-+ if (qmlGraphicsItem()->height() < 10.)
-+ qmlGraphicsItem()->setHeight(100.);
- qmlGraphicsItem()->blockSignals(false);
- }
- }
-diff --git a/src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp
-index f350af0..5d89ba9 100644
---- a/src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp
-+++ b/src/plugins/qmldesigner/designercore/metainfo/metainfo.cpp
-@@ -526,6 +526,13 @@ QString MetaInfo::fromQtTypes(const QString &type) const
- return type;
- }
-
-+void MetaInfo::inheritFrom(MetaInfo &other)
-+{
-+ if (other.m_p.isNull())
-+ return;
-+ m_p = other.m_p;
-+}
-+
- /*!
- \brief Returns whether an enumerator is registered in the meta type system.
- */
-diff --git a/src/plugins/qmldesigner/designercore/metainfo/propertymetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/propertymetainfo.cpp
-index 9e84ae0..f7c3b1e 100644
---- a/src/plugins/qmldesigner/designercore/metainfo/propertymetainfo.cpp
-+++ b/src/plugins/qmldesigner/designercore/metainfo/propertymetainfo.cpp
-@@ -270,7 +270,8 @@ bool PropertyMetaInfo::isListProperty() const
- throw InvalidMetaInfoException(__LINE__, Q_FUNC_INFO, __FILE__);
- }
-
-- return type().contains("QDeclarativeList");
-+ return type().contains("QDeclarativeList") ||
-+ type().contains("alias"); //### this is a nasty hack - we have to get instances in to resolve this properly
- }
-
- /*!
-diff --git a/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp b/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
-index 03bbde7..635f954 100644
---- a/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
-+++ b/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
-@@ -114,7 +114,7 @@ SubComponentManagerPrivate::SubComponentManagerPrivate(MetaInfo metaInfo, SubCom
- m_metaInfo(metaInfo)
- {
- connect(&m_watcher, SIGNAL(directoryChanged(QString)), this, SLOT(parseDirectory(QString)));
-- connect(&m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(parseFile(QString)));
-+ connect(&m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(parseFile(QString, QString)));
- }
-
- void SubComponentManagerPrivate::addImport(int pos, const QDeclarativeDomImport &import)
-diff --git a/src/plugins/qmldesigner/designercore/model/modelmerger.cpp b/src/plugins/qmldesigner/designercore/model/modelmerger.cpp
-index 7e9290c..0184d64 100644
---- a/src/plugins/qmldesigner/designercore/model/modelmerger.cpp
-+++ b/src/plugins/qmldesigner/designercore/model/modelmerger.cpp
-@@ -38,6 +38,7 @@
- #include "bindingproperty.h"
- #include "variantproperty.h"
- #include "rewritertransaction.h"
-+#include <rewritingexception.h>
-
- #include <QSet>
- #include <QStringList>
-@@ -61,6 +62,8 @@ static QString fixExpression(const QString &expression, const QHash<QString, QSt
- static void syncVariantProperties(ModelNode &outputNode, const ModelNode &inputNode)
- {
- foreach (const VariantProperty &variantProperty, inputNode.variantProperties()) {
-+ qDebug() << variantProperty.name();
-+ qDebug() << variantProperty.value();
- outputNode.variantProperty(variantProperty.name()) = variantProperty.value();
- }
- }
-@@ -168,26 +171,30 @@ ModelNode ModelMerger::insertModel(const ModelNode &modelNode)
-
- void ModelMerger::replaceModel(const ModelNode &modelNode)
- {
-- RewriterTransaction transaction(view()->beginRewriterTransaction());
-+ try {
-+ RewriterTransaction transaction(view()->beginRewriterTransaction());
-
-- foreach (const Import &import, modelNode.model()->imports())
-- view()->model()->addImport(import);
-- view()->model()->setFileUrl(modelNode.model()->fileUrl());
-+ foreach (const Import &import, modelNode.model()->imports())
-+ view()->model()->addImport(import);
-+ view()->model()->setFileUrl(modelNode.model()->fileUrl());
-
-- ModelNode rootNode(view()->rootModelNode());
-+ ModelNode rootNode(view()->rootModelNode());
-
-- foreach (const QString &propertyName, rootNode.propertyNames())
-- rootNode.removeProperty(propertyName);
-+ foreach (const QString &propertyName, rootNode.propertyNames())
-+ rootNode.removeProperty(propertyName);
-
-- QHash<QString, QString> idRenamingHash;
-- setupIdRenamingHash(modelNode, idRenamingHash, view());
-+ QHash<QString, QString> idRenamingHash;
-+ setupIdRenamingHash(modelNode, idRenamingHash, view());
-
-- syncVariantProperties(rootNode, modelNode);
-- syncBindingProperties(rootNode, modelNode, idRenamingHash);
-- syncId(rootNode, modelNode, idRenamingHash);
-- syncNodeProperties(rootNode, modelNode, idRenamingHash, view());
-- syncNodeListProperties(rootNode, modelNode, idRenamingHash, view());
-- m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion());
-+ syncVariantProperties(rootNode, modelNode);
-+ syncBindingProperties(rootNode, modelNode, idRenamingHash);
-+ syncId(rootNode, modelNode, idRenamingHash);
-+ syncNodeProperties(rootNode, modelNode, idRenamingHash, view());
-+ syncNodeListProperties(rootNode, modelNode, idRenamingHash, view());
-+ m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion());
-+ } catch (RewritingException &e) {
-+ qWarning() << e.description(); //silent error
-+ }
- }
-
- } //namespace QmlDesigner
-diff --git a/src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp b/src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp
-index 002550c..da19e7b 100644
---- a/src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp
-+++ b/src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp
-@@ -1,7 +1,4 @@
--/**************************************************************************
--**
--** This file is part of Qt Creator
--**
-+/**
- ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
- **
- ** Contact: Nokia Corporation (qt-info@nokia.com)
-diff --git a/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp b/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp
-index 1df6106..6704469 100644
---- a/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp
-+++ b/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp
-@@ -326,7 +326,7 @@ AnchorLine QmlAnchors::instanceAnchor(AnchorLine::Type sourceAnchorLine) const
- if (targetAnchorLine == AnchorLine::Invalid )
- return AnchorLine();
-
-- Q_ASSERT(targetAnchorLinePair.second.isValid());
-+ //Q_ASSERT(targetAnchorLinePair.second.isValid()); //### todo proper fix
- return AnchorLine(QmlItemNode(qmlItemNode().nodeForInstance(targetAnchorLinePair.second)), targetAnchorLine);
- }
-
-diff --git a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp
-index 13d6e94..2d60b2a 100644
---- a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp
-+++ b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp
-@@ -155,7 +155,6 @@ QList<QmlObjectNode> QmlItemNode::allDirectSubNodes() const
- QList<ModelNode> modelNodeList = modelNode().allDirectSubModelNodes();
-
- foreach (const ModelNode &node, modelNodeList) {
-- if (!QmlItemNode(node).isValid()) //if ModelNode is no FxItem
- returnList.append(node);
- }
- }
-diff --git a/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp b/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp
-index d0885e7..784e0dd 100644
---- a/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp
-+++ b/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp
-@@ -200,7 +200,7 @@ QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryE
- parentNode.nodeAbstractProperty(parentNode.defaultProperty()).reparentHere(newNode);
- }
-
-- Q_ASSERT(newNode.isValid());
-+ //Q_ASSERT(newNode.isValid());
-
- QString id;
- int i = 1;
-@@ -224,10 +224,10 @@ QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryE
- newNode.setVariantProperty("opacity", 1);
- }
-
-- Q_ASSERT(newNode.isValid());
-+ //Q_ASSERT(newNode.isValid());
- }
-
-- Q_ASSERT(newNode.isValid());
-+ //Q_ASSERT(newNode.isValid());
-
- return newNode;
- }
-diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
-index 59b1522..4f9946e 100644
---- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
-+++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
-@@ -216,7 +216,7 @@ public:
- typeName = qmlValue->packageName() + QLatin1String("/") + qmlValue->className();
- majorVersion = qmlValue->version().major();
- minorVersion = qmlValue->version().minor();
-- } else if (value) {
-+ } else {
- for (UiQualifiedId *iter = astTypeNode; iter; iter = iter->next)
- if (!iter->next && iter->name)
- typeName = iter->name->asString();
-@@ -711,6 +711,8 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
- const QString astType = property->memberType->asString();
- AbstractProperty modelProperty = modelNode.property(astName);
- if (!property->expression || isLiteralValue(property->expression)) {
-+ qDebug() << astName;
-+ qDebug() << astType;
- const QVariant variantValue = convertDynamicPropertyValueToVariant(astValue, astType);
- syncVariantProperty(modelProperty, variantValue, astType, differenceHandler);
- } else {
-diff --git a/src/plugins/qmldesigner/qmldesigner.pro b/src/plugins/qmldesigner/qmldesigner.pro
-index 28abb28..baede56 100644
---- a/src/plugins/qmldesigner/qmldesigner.pro
-+++ b/src/plugins/qmldesigner/qmldesigner.pro
-@@ -1,3 +1,3 @@
- TEMPLATE = subdirs
-
--SUBDIRS = qmldesignerplugin.pro fxplugin
-+SUBDIRS = qmldesignerplugin.pro fxplugin mxplugin