Commit 2a425c7c authored by Kai Koehne's avatar Kai Koehne

Fix bug where a qml error shown in Design mode were not updated

If you continue to fix qml errors in text mode, but still had errors,
the error message you got in the Design mode always stayed the first
(outdated) error message.
parent a22e64a0
......@@ -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;
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
}
}
......
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