mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-27 01:09:48 +01:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user