Commit c6e1bf61 authored by Ulf Hermann's avatar Ulf Hermann

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: default avatarMarco Benelli <marco.benelli@qt.io>
parent 0c6d5d6a
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment