From 5407eedad7439b27950b4b07b985ae4c2fba7a83 Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Mon, 9 Apr 2018 07:42:59 +0800 Subject: [PATCH] Fix undo/redo --- src/skeletondocument.cpp | 8 ++++++-- src/skeletondocumentwindow.cpp | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/skeletondocument.cpp b/src/skeletondocument.cpp index fc1a5372..56221e87 100644 --- a/src/skeletondocument.cpp +++ b/src/skeletondocument.cpp @@ -577,11 +577,15 @@ void SkeletonDocument::fromSnapshot(const SkeletonSnapshot &snapshot) edge.partId = QUuid(valueOfKeyInMapOrEmpty(edgeKv.second, "partId")); edge.branchMode = SkeletonEdgeBranchModeFromString(valueOfKeyInMapOrEmpty(edgeKv.second, "branchMode")); QString fromNodeId = valueOfKeyInMapOrEmpty(edgeKv.second, "from"); - if (!fromNodeId.isEmpty()) + if (!fromNodeId.isEmpty()) { edge.nodeIds.push_back(QUuid(fromNodeId)); + nodeMap[QUuid(fromNodeId)].edgeIds.push_back(edge.id); + } QString toNodeId = valueOfKeyInMapOrEmpty(edgeKv.second, "to"); - if (!toNodeId.isEmpty()) + if (!toNodeId.isEmpty()) { edge.nodeIds.push_back(QUuid(toNodeId)); + nodeMap[QUuid(toNodeId)].edgeIds.push_back(edge.id); + } edgeMap[edge.id] = edge; } for (const auto &partKv : snapshot.parts) { diff --git a/src/skeletondocumentwindow.cpp b/src/skeletondocumentwindow.cpp index 93161842..f55959e8 100644 --- a/src/skeletondocumentwindow.cpp +++ b/src/skeletondocumentwindow.cpp @@ -219,6 +219,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : }); connect(this, &SkeletonDocumentWindow::initialized, m_document, [=]() { + m_document->saveSnapshot(); graphicsWidget->setFocus(); });