OSDN Git Service

QmlDesigner.documentController: fix text design synchronisation
authorThomas Hartmann <Thomas.Hartmann@nokia.com>
Wed, 8 Jun 2011 15:25:28 +0000 (17:25 +0200)
committerThomas Hartmann <Thomas.Hartmann@nokia.com>
Wed, 8 Jun 2011 15:26:08 +0000 (17:26 +0200)
The synchronisation of selection between text and designmode was broken.
This fixes a regression.

Change-Id: I4d3fd2f9716398a16e01ce3d389d099bfad1f66b
Reviewed-on: http://codereview.qt.nokia.com/401
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
src/plugins/qmldesigner/designmodewidget.cpp

index cf4b902..ded3e62 100644 (file)
@@ -536,9 +536,13 @@ void DesignModeWidget::setAutoSynchronization(bool sync)
     if (debug)
         qDebug() << Q_FUNC_INFO << sync;
 
+    RewriterView *rewriter = m_currentDesignDocumentController->rewriterView();
+
     m_currentDesignDocumentController->blockModelSync(!sync);
 
     if (sync) {
+        if (rewriter && m_currentDesignDocumentController->model())
+            rewriter->setSelectedModelNodes(QList<ModelNode>());
         // text editor -> visual editor
         if (!m_currentDesignDocumentController->model()) {
             m_currentDesignDocumentController->loadMaster(m_currentTextEdit.data());
@@ -549,10 +553,9 @@ void DesignModeWidget::setAutoSynchronization(bool sync)
         QList<RewriterView::Error> errors = m_currentDesignDocumentController->qmlErrors();
         if (errors.isEmpty()) {
             // set selection to text cursor
-            RewriterView *rewriter = m_currentDesignDocumentController->rewriterView();
             const int cursorPos = m_currentTextEdit->textCursor().position();
             ModelNode node = nodeForPosition(cursorPos);
-            if (node.isValid()) {
+            if (rewriter && node.isValid()) {
                 rewriter->setSelectedModelNodes(QList<ModelNode>() << node);
             }
             enable();