From c6e1bf6187618399860c4f3041c5f7cd725bd080 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 22 Mar 2017 14:23:41 +0100 Subject: [PATCH] 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 --- .../scxmleditor/plugin_interface/scutilsprovider.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/scxmleditor/plugin_interface/scutilsprovider.cpp b/src/plugins/scxmleditor/plugin_interface/scutilsprovider.cpp index 89dc7bbdb0b..b4b0f227426 100644 --- a/src/plugins/scxmleditor/plugin_interface/scutilsprovider.cpp +++ b/src/plugins/scxmleditor/plugin_interface/scutilsprovider.cpp @@ -45,7 +45,10 @@ void SCUtilsProvider::checkInitialState(const QList &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 &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