QmlDesigner: Use single transaction to add state

The QtQuick import has to exist.

Change-Id: I2184a6981b8307b593bddcc2feba8dee28a7eaf3
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2020-11-12 13:21:24 +01:00
parent 80be8c2b14
commit d2293204d4

View File

@@ -192,17 +192,12 @@ void StatesEditorView::addState()
break;
}
try {
executeInTransaction("addState", [this, newStateName]() {
rootModelNode().validId();
if ((rootStateGroup().allStates().count() < 1) && //QtQuick import might be missing
(!model()->hasImport(Import::createLibraryImport("QtQuick", "1.0"), true, true))) {
model()->changeImports({Import::createLibraryImport("QtQuick", "1.0")}, {});
}
ModelNode newState = rootStateGroup().addState(newStateName);
setCurrentState(newState);
} catch (const RewritingException &e) {
e.showException();
}
});
}
void StatesEditorView::resetModel()