From a168e2ccfc451a97adfa34bb8549c679cd675c67 Mon Sep 17 00:00:00 2001 From: maj00r Date: Wed, 21 Oct 2026 08:59:54 +0200 Subject: [PATCH] fix(editor): an undo no longer moves a model which took the place of a deleted one The states of the objects which followed a track, kept in the history for the undo, held the pointer of a model after it was deleted. Only the address was checked before the model was moved back, so a node made later at the same address, of another type too, was taken for it. The states of a deleted model are dropped from the history with its other pointers. --- application/editormode.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/application/editormode.cpp b/application/editormode.cpp index 0b2ee811..0dd4c8ee 100644 --- a/application/editormode.cpp +++ b/application/editormode.cpp @@ -874,6 +874,7 @@ void editor_mode::nullify_history_pointers(scene::basic_node *node) ui()->set_node(nullptr); infra_forget(node); + auto const followed = [node](infra::object_state const &State) { return State.saved.node == node; }; for (auto &s : m_history) { if (s.node_ptr == node) @@ -883,12 +884,14 @@ void editor_mode::nullify_history_pointers(scene::basic_node *node) if (copy.model == node) copy.model = nullptr; } + s.infra.erase(std::remove_if(s.infra.begin(), s.infra.end(), followed), s.infra.end()); } for (auto &s : g_redo) { if (s.node_ptr == node) s.node_ptr = nullptr; + s.infra.erase(std::remove_if(s.infra.begin(), s.infra.end(), followed), s.infra.end()); } // deleted nodes also drop out of the "undo last fill" set