diff --git a/src/plugins/qmldesigner/core/include/rewriterview.h b/src/plugins/qmldesigner/core/include/rewriterview.h index 4806bf41b97ca8818bf3fe1b874bd31d8a87de27..e360736c8baf2ca3b5651a2461ffa140acb2f72d 100644 --- a/src/plugins/qmldesigner/core/include/rewriterview.h +++ b/src/plugins/qmldesigner/core/include/rewriterview.h @@ -137,7 +137,7 @@ public: QList<Error> errors() const; void clearErrors(); - void addErrors(const QList<Error> &errors); + void setErrors(const QList<Error> &errors); void addError(const Error &error); QMap<ModelNode, QString> extractText(const QList<ModelNode> &nodes) const; diff --git a/src/plugins/qmldesigner/core/model/rewriterview.cpp b/src/plugins/qmldesigner/core/model/rewriterview.cpp index ea754e2efa6a781511b3f5cd977adb7e36b0088f..4308c95172446304aa0fcd910da009b5ac22cd39 100644 --- a/src/plugins/qmldesigner/core/model/rewriterview.cpp +++ b/src/plugins/qmldesigner/core/model/rewriterview.cpp @@ -376,9 +376,9 @@ void RewriterView::clearErrors() emit errorsChanged(m_errors); } -void RewriterView::addErrors(const QList<RewriterView::Error> &errors) +void RewriterView::setErrors(const QList<RewriterView::Error> &errors) { - m_errors.append(errors); + m_errors = errors; emit errorsChanged(m_errors); } diff --git a/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp index f3e0d57fbe3df1268f3edd75ebd6d39a9a4982dc..3b844749e2d7d3d5b52983a7e1e99a6bb415dd15 100644 --- a/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp @@ -104,7 +104,7 @@ bool TextToModelMerger::load(const QByteArray &data, DifferenceHandler &differen QList<RewriterView::Error> errors; foreach (const QmlError &qmlError, doc.errors()) errors.append(RewriterView::Error(qmlError)); - m_rewriterView->addErrors(errors); + m_rewriterView->setErrors(errors); } setActive(false); diff --git a/src/plugins/qmldesigner/designmodewidget.cpp b/src/plugins/qmldesigner/designmodewidget.cpp index 51c4c53981b74f6086fc4d47623e0cf8ed76ee07..71a5159a31f72b1ace07f45ef740590fd16e013e 100644 --- a/src/plugins/qmldesigner/designmodewidget.cpp +++ b/src/plugins/qmldesigner/designmodewidget.cpp @@ -281,27 +281,30 @@ void DocumentWidget::setAutoSynchronization(bool sync) if (sync) { // text editor -> visual editor - if (!m_document->model()) { - QList<RewriterView::Error> errors = m_document->loadMaster(m_textBuffer.data()); + if (!document()->model()) { + // first initialization + QList<RewriterView::Error> errors = document()->loadMaster(m_textBuffer.data()); if (!errors.isEmpty()) { disable(errors); - } else { - connect(m_document, SIGNAL(qmlErrorsChanged(QList<RewriterView::Error>)), - this, SLOT(updateErrorStatus(QList<RewriterView::Error>))); } } - if (m_document->model() && m_document->qmlErrors().isEmpty()) { + if (document()->model() && document()->qmlErrors().isEmpty()) { // set selection to text cursor - RewriterView *rewriter = m_document->rewriterView(); + RewriterView *rewriter = document()->rewriterView(); const int cursorPos = m_textBuffer->textCursor().position(); ModelNode node = nodeForPosition(cursorPos); if (node.isValid()) { rewriter->setSelectedModelNodes(QList<ModelNode>() << node); } + enable(); } + + connect(document(), SIGNAL(qmlErrorsChanged(QList<RewriterView::Error>)), + this, SLOT(updateErrorStatus(QList<RewriterView::Error>))); + } else { - if (m_document->model() && m_document->qmlErrors().isEmpty()) { - RewriterView *rewriter = m_document->rewriterView(); + if (document()->model() && document()->qmlErrors().isEmpty()) { + RewriterView *rewriter = document()->rewriterView(); // visual editor -> text editor ModelNode selectedNode; if (!rewriter->selectedModelNodes().isEmpty()) @@ -319,6 +322,9 @@ void DocumentWidget::setAutoSynchronization(bool sync) } } } + + disconnect(document(), SIGNAL(qmlErrorsChanged(QList<RewriterView::Error>)), + this, SLOT(updateErrorStatus(QList<RewriterView::Error>))); } } @@ -350,7 +356,7 @@ void DocumentWidget::updateErrorStatus(const QList<RewriterView::Error> &errors) { if (m_isDisabled && errors.isEmpty()) { enable(); - } else if (!m_isDisabled && !errors.isEmpty()) { + } else if (!errors.isEmpty()) { disable(errors); } }