Commit 66b87a17 authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Changed certain error cases to throw exceptions, as the higher-levels expect.

parent 01c09899
......@@ -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();
......
......@@ -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) {
......
Supports Markdown
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