forked from qt-creator/qt-creator
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:
@@ -192,17 +192,12 @@ void StatesEditorView::addState()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
executeInTransaction("addState", [this, newStateName]() {
|
||||||
rootModelNode().validId();
|
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);
|
ModelNode newState = rootStateGroup().addState(newStateName);
|
||||||
setCurrentState(newState);
|
setCurrentState(newState);
|
||||||
} catch (const RewritingException &e) {
|
});
|
||||||
e.showException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatesEditorView::resetModel()
|
void StatesEditorView::resetModel()
|
||||||
@@ -303,7 +298,7 @@ void StatesEditorView::renameState(int internalNodeId, const QString &newName)
|
|||||||
|
|
||||||
setCurrentState(oldState);
|
setCurrentState(oldState);
|
||||||
}
|
}
|
||||||
} catch (const RewritingException &e) {
|
} catch (const RewritingException &e) {
|
||||||
e.showException();
|
e.showException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user