Fix undo/redo

master
Jeremy Hu 2018-04-09 07:42:59 +08:00
parent 35a62960ca
commit 5407eedad7
2 changed files with 7 additions and 2 deletions

View File

@ -577,11 +577,15 @@ void SkeletonDocument::fromSnapshot(const SkeletonSnapshot &snapshot)
edge.partId = QUuid(valueOfKeyInMapOrEmpty(edgeKv.second, "partId")); edge.partId = QUuid(valueOfKeyInMapOrEmpty(edgeKv.second, "partId"));
edge.branchMode = SkeletonEdgeBranchModeFromString(valueOfKeyInMapOrEmpty(edgeKv.second, "branchMode")); edge.branchMode = SkeletonEdgeBranchModeFromString(valueOfKeyInMapOrEmpty(edgeKv.second, "branchMode"));
QString fromNodeId = valueOfKeyInMapOrEmpty(edgeKv.second, "from"); QString fromNodeId = valueOfKeyInMapOrEmpty(edgeKv.second, "from");
if (!fromNodeId.isEmpty()) if (!fromNodeId.isEmpty()) {
edge.nodeIds.push_back(QUuid(fromNodeId)); edge.nodeIds.push_back(QUuid(fromNodeId));
nodeMap[QUuid(fromNodeId)].edgeIds.push_back(edge.id);
}
QString toNodeId = valueOfKeyInMapOrEmpty(edgeKv.second, "to"); QString toNodeId = valueOfKeyInMapOrEmpty(edgeKv.second, "to");
if (!toNodeId.isEmpty()) if (!toNodeId.isEmpty()) {
edge.nodeIds.push_back(QUuid(toNodeId)); edge.nodeIds.push_back(QUuid(toNodeId));
nodeMap[QUuid(toNodeId)].edgeIds.push_back(edge.id);
}
edgeMap[edge.id] = edge; edgeMap[edge.id] = edge;
} }
for (const auto &partKv : snapshot.parts) { for (const auto &partKv : snapshot.parts) {

View File

@ -219,6 +219,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
}); });
connect(this, &SkeletonDocumentWindow::initialized, m_document, [=]() { connect(this, &SkeletonDocumentWindow::initialized, m_document, [=]() {
m_document->saveSnapshot();
graphicsWidget->setFocus(); graphicsWidget->setFocus();
}); });