aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2020-11-12 13:21:24 +0100
committerThomas Hartmann <thomas.hartmann@qt.io>2020-11-12 13:51:05 +0000
commitd2293204d4b942ccdede1493ee1ac91f77a5ad5c (patch)
tree7cd6ac6f748635647428e4c321b464af7622dd8f
parent80be8c2b142febf01a5e5c4449f2e8f919a4845a (diff)
QmlDesigner: Use single transaction to add state
The QtQuick import has to exist. Change-Id: I2184a6981b8307b593bddcc2feba8dee28a7eaf3 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp
index b777fbf4c2..8eebe7211a 100644
--- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp
+++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp
@@ -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()
@@ -303,7 +298,7 @@ void StatesEditorView::renameState(int internalNodeId, const QString &newName)
setCurrentState(oldState);
}
- } catch (const RewritingException &e) {
+ } catch (const RewritingException &e) {
e.showException();
}
}