summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2019-06-27 15:02:53 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2019-06-28 16:48:22 +0300
commite68da593533e4d1fd321f7b5ae97a7b61a19abdc (patch)
tree21031c4d1f52678380a6b15e59e6bb72f6b96975
parent50a696826e2e1295f0cbb8c516146f781b463b59 (diff)
Remove manually deleted subpresentations from .uia
Task-number: QT3DS-2431 Change-Id: I3ff69e04a4099988577161a59bf22d9f3c0bafd0 Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
-rw-r--r--src/Authoring/Qt3DStudio/Application/ProjectFile.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/Authoring/Qt3DStudio/Application/ProjectFile.cpp b/src/Authoring/Qt3DStudio/Application/ProjectFile.cpp
index b4c18c50..d7c21a95 100644
--- a/src/Authoring/Qt3DStudio/Application/ProjectFile.cpp
+++ b/src/Authoring/Qt3DStudio/Application/ProjectFile.cpp
@@ -546,9 +546,11 @@ void ProjectFile::loadSubpresentationsAndDatainputs(
m_initialPresentation = g_StudioApp.GetCore()->GetDoc()->getPresentationId();
QDomDocument doc;
- if (!StudioUtils::readFileToDomDocument(getProjectFilePath(), doc))
+ QSaveFile projectFile(getProjectFilePath());
+ if (!StudioUtils::openDomDocumentSave(projectFile, doc))
return;
+ QVector<QDomElement> removedElements;
QDomElement assetsElem = doc.documentElement().firstChildElement(QStringLiteral("assets"));
if (!assetsElem.isNull()) {
QString initial = assetsElem.attribute(QStringLiteral("initial"));
@@ -563,13 +565,24 @@ void ProjectFile::loadSubpresentationsAndDatainputs(
QString argsOrSrc = p.attribute(QStringLiteral("src"));
if (argsOrSrc.isNull())
argsOrSrc = p.attribute(QStringLiteral("args"));
- subpresentations.push_back(
- SubPresentationRecord(p.nodeName(), p.attribute("id"), argsOrSrc));
+ // Skip non-existent presentations (they have been manually deleted)
+ if (QFileInfo().exists(getAbsoluteFilePathTo(argsOrSrc))) {
+ subpresentations.push_back(
+ SubPresentationRecord(p.nodeName(), p.attribute("id"), argsOrSrc));
+ } else {
+ removedElements.append(p);
+ }
} else {
parseDataInputElem(p, datainputs);
}
}
}
+ if (removedElements.size()) {
+ for (auto &elem : qAsConst(removedElements))
+ assetsElem.removeChild(elem);
+ StudioUtils::commitDomDocumentSave(projectFile, doc);
+ }
+
g_StudioApp.GetCore()->GetDoc()->UpdateDatainputMap();
}