forked from qt-creator/qt-creator
ScxmlEditor: Retain explicitly set "initial" attributes
If the user sets a state to be initial and then moves it around without reparenting it, the initial attribute has to be retained. This is achieved by saving a "removedInitial" attribute in the editor info when the state is released from its parent and restoring the attribute when it is reattached. This even works if the state is temporarily reparented and across save/load cycles. Change-Id: I65df959e4eb8d46177d59f71c8556d596e773c05 Task-number: QTCREATORBUG-17108 Reviewed-by: Marco Benelli <marco.benelli@qt.io>
This commit is contained in:
@@ -45,7 +45,10 @@ void SCUtilsProvider::checkInitialState(const QList<QGraphicsItem*> &items, Scxm
|
||||
if (parentTag->hasChild(Initial)) {
|
||||
parentTag->setAttribute("initial", QString());
|
||||
} else {
|
||||
QString restoredInitial = parentTag->editorInfo("removedInitial");
|
||||
QString id = parentTag->attribute("initial");
|
||||
if (id.isEmpty())
|
||||
id = restoredInitial;
|
||||
|
||||
// 2. If no initial-state available, try to find state with initial-attribute
|
||||
if (!id.isEmpty()) {
|
||||
@@ -59,8 +62,13 @@ void SCUtilsProvider::checkInitialState(const QList<QGraphicsItem*> &items, Scxm
|
||||
}
|
||||
}
|
||||
|
||||
if (!initialStateTag)
|
||||
if (!initialStateTag) {
|
||||
parentTag->setEditorInfo("removedInitial", id);
|
||||
parentTag->setAttribute("initial", QString());
|
||||
} else if (id == restoredInitial) {
|
||||
parentTag->setAttribute("initial", id);
|
||||
parentTag->setEditorInfo("removedInitial", QString());
|
||||
}
|
||||
}
|
||||
|
||||
// 3. If we still cant find initial-state, we must select first
|
||||
|
||||
Reference in New Issue
Block a user