diff --git a/plugins/builtin/include/content/views/view_data_processor.hpp b/plugins/builtin/include/content/views/view_data_processor.hpp index db155e3ef..7163fb9db 100644 --- a/plugins/builtin/include/content/views/view_data_processor.hpp +++ b/plugins/builtin/include/content/views/view_data_processor.hpp @@ -44,8 +44,8 @@ namespace hex::plugin::builtin { static nlohmann::json saveNode(const dp::Node *node); static nlohmann::json saveNodes(const Workspace &workspace); - static std::unique_ptr loadNode(const nlohmann::json &data); - static void loadNodes(Workspace &workspace, const nlohmann::json &data); + static std::unique_ptr loadNode(nlohmann::json data); + void loadNodes(Workspace &workspace, nlohmann::json data); static void eraseLink(Workspace &workspace, int id); static void eraseNodes(Workspace &workspace, const std::vector &ids); diff --git a/plugins/builtin/source/content/views/view_data_processor.cpp b/plugins/builtin/source/content/views/view_data_processor.cpp index 25377f5f6..912b4295a 100644 --- a/plugins/builtin/source/content/views/view_data_processor.cpp +++ b/plugins/builtin/source/content/views/view_data_processor.cpp @@ -397,7 +397,7 @@ namespace hex::plugin::builtin { [&](const std::fs::path &path) { wolv::io::File file(path, wolv::io::File::Mode::Read); if (file.isValid()) { - ViewDataProcessor::loadNodes(*this->m_mainWorkspace, file.readString()); + ViewDataProcessor::loadNodes(*this->m_mainWorkspace, nlohmann::json::parse(file.readString())); this->m_updateNodePositions = true; } }); @@ -747,7 +747,6 @@ namespace hex::plugin::builtin { // If a node position update is pending, update the node position int nodeId = node.getId(); if (this->m_updateNodePositions) { - this->m_updateNodePositions = false; ImNodes::SetNodeGridSpacePos(nodeId, node.getPosition()); } else { if (ImNodes::ObjectPoolFind(ImNodes::EditorContextGet().Nodes, nodeId) >= 0) @@ -882,6 +881,8 @@ namespace hex::plugin::builtin { ImNodes::PopColorStyle(); } + this->m_updateNodePositions = false; + // Handle removing links that are connected to attributes that don't exist anymore { std::vector linksToRemove; @@ -1074,7 +1075,7 @@ namespace hex::plugin::builtin { return output; } - std::unique_ptr ViewDataProcessor::loadNode(const nlohmann::json &node) { + std::unique_ptr ViewDataProcessor::loadNode(nlohmann::json node) { try { auto &nodeEntries = ContentRegistry::DataProcessorNode::impl::getEntries(); @@ -1108,7 +1109,7 @@ namespace hex::plugin::builtin { } } - void ViewDataProcessor::loadNodes(ViewDataProcessor::Workspace &workspace, const nlohmann::json &jsonData) { + void ViewDataProcessor::loadNodes(ViewDataProcessor::Workspace &workspace, nlohmann::json jsonData) { workspace.nodes.clear(); workspace.endNodes.clear(); workspace.links.clear(); @@ -1194,7 +1195,7 @@ namespace hex::plugin::builtin { dp::Attribute::setIdCounter(maxAttrId + 1); dp::Link::setIdCounter(maxLinkId + 1); - ViewDataProcessor::processNodes(workspace); + this->m_updateNodePositions = true; } catch (nlohmann::json::exception &e) { PopupError::open(hex::format("Failed to load nodes: {}", e.what())); }