forked from qt-creator/qt-creator
QmlDesigner: Fix crash in tests
In the tests we have cases with no rewriter attached. We warn in these cases. Change-Id: Ibc89ff501bf6d48ed3a2f230ee6e1afda5d4d06c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
#include <abstractview.h>
|
||||
#include <rewriterview.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#ifndef QMLDESIGNER_TEST
|
||||
#include <designdocument.h>
|
||||
#include <qmldesignerplugin.h>
|
||||
@@ -82,13 +84,22 @@ void RewriterTransaction::commit()
|
||||
{
|
||||
if (m_valid) {
|
||||
m_valid = false;
|
||||
bool oldSemanticChecks = view()->rewriterView()->checkSemanticErrors();
|
||||
if (m_ignoreSemanticChecks)
|
||||
view()->rewriterView()->setCheckSemanticErrors(false);
|
||||
|
||||
RewriterView *rewriterView = view()->rewriterView();
|
||||
|
||||
QTC_ASSERT(rewriterView, qWarning() << Q_FUNC_INFO << "No rewriter attached");
|
||||
|
||||
bool oldSemanticChecks = false;
|
||||
if (rewriterView) {
|
||||
oldSemanticChecks = rewriterView->checkSemanticErrors();
|
||||
if (m_ignoreSemanticChecks)
|
||||
rewriterView->setCheckSemanticErrors(false);
|
||||
}
|
||||
|
||||
view()->emitRewriterEndTransaction();
|
||||
|
||||
view()->rewriterView()->setCheckSemanticErrors(oldSemanticChecks);
|
||||
if (rewriterView)
|
||||
view()->rewriterView()->setCheckSemanticErrors(oldSemanticChecks);
|
||||
|
||||
if (m_activeIdentifier) {
|
||||
qDebug() << "Commit RewriterTransaction:" << m_identifier << m_identifierNumber;
|
||||
|
Reference in New Issue
Block a user