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 <abstractview.h>
|
||||||
#include <rewriterview.h>
|
#include <rewriterview.h>
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#ifndef QMLDESIGNER_TEST
|
#ifndef QMLDESIGNER_TEST
|
||||||
#include <designdocument.h>
|
#include <designdocument.h>
|
||||||
#include <qmldesignerplugin.h>
|
#include <qmldesignerplugin.h>
|
||||||
@@ -82,12 +84,21 @@ void RewriterTransaction::commit()
|
|||||||
{
|
{
|
||||||
if (m_valid) {
|
if (m_valid) {
|
||||||
m_valid = false;
|
m_valid = false;
|
||||||
bool oldSemanticChecks = view()->rewriterView()->checkSemanticErrors();
|
|
||||||
|
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)
|
if (m_ignoreSemanticChecks)
|
||||||
view()->rewriterView()->setCheckSemanticErrors(false);
|
rewriterView->setCheckSemanticErrors(false);
|
||||||
|
}
|
||||||
|
|
||||||
view()->emitRewriterEndTransaction();
|
view()->emitRewriterEndTransaction();
|
||||||
|
|
||||||
|
if (rewriterView)
|
||||||
view()->rewriterView()->setCheckSemanticErrors(oldSemanticChecks);
|
view()->rewriterView()->setCheckSemanticErrors(oldSemanticChecks);
|
||||||
|
|
||||||
if (m_activeIdentifier) {
|
if (m_activeIdentifier) {
|
||||||
|
Reference in New Issue
Block a user