diff --git a/src/plugins/qmldesigner/core/model/rewriterview.cpp b/src/plugins/qmldesigner/core/model/rewriterview.cpp index 361e459bb3d5b5e1bdb7873327ec0a0f199c8267..9fa5b1e46c38092384bf6d62573f54e3a7fa4057 100644 --- a/src/plugins/qmldesigner/core/model/rewriterview.cpp +++ b/src/plugins/qmldesigner/core/model/rewriterview.cpp @@ -396,6 +396,8 @@ void RewriterView::applyModificationGroupChanges() void RewriterView::applyChanges() { + clearErrors(); + if (inErrorState()) { qDebug() << "RewriterView::applyChanges() got called while in error state. Will do a quick-exit now."; throw RewritingException(__LINE__, __FUNCTION__, __FILE__, "RewriterView::applyChanges() already in error state"); @@ -403,6 +405,9 @@ void RewriterView::applyChanges() try { modelToTextMerger()->applyChanges(); + if (!errors().isEmpty()) { + enterErrorState(errors().first().description()); + } } catch (Exception &e) { enterErrorState(e.description()); } @@ -445,7 +450,6 @@ void RewriterView::resetToLastCorrectQml() m_textModifier->textDocument()->undo(); m_textModifier->textDocument()->clearUndoRedoStacks(QTextDocument::RedoStack); ModelAmender differenceHandler(m_textToModelMerger.data()); -// m_textToModelMerger->load(lastCorrectQmlSource.toUtf8(), differenceHandler); m_textToModelMerger->load(m_textModifier->text().toUtf8(), differenceHandler); leaveErrorState(); diff --git a/tests/auto/qml/qmldesigner/coretests/testcore.cpp b/tests/auto/qml/qmldesigner/coretests/testcore.cpp index 25604f4b8cdfd3187f6a5a2f8fabc6c55d557fe9..dcdc8713cbe4a3d33ea9df730283fae3a88df84a 100644 --- a/tests/auto/qml/qmldesigner/coretests/testcore.cpp +++ b/tests/auto/qml/qmldesigner/coretests/testcore.cpp @@ -2562,7 +2562,7 @@ void TestCore::testRewriterExceptionHandling() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("Qt/Item", 4, 6)); + QScopedPointer<Model> model(Model::create("Qt/Text", 4, 6)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView); @@ -2580,8 +2580,8 @@ void TestCore::testRewriterExceptionHandling() try { RewriterTransaction transaction = view->beginRewriterTransaction(); - rootNode.variantProperty("bla") = QVariant("blah\""); rootNode.variantProperty("text") = QVariant("text"); + rootNode.variantProperty("bla") = QVariant("blah"); transaction.commit(); QFAIL("RewritingException should be thrown"); } catch (RewritingException &e) {