mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-29 18:37:29 +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);
|
ui()->set_node(nullptr);
|
||||||
infra_forget(node);
|
infra_forget(node);
|
||||||
|
|
||||||
|
auto const followed = [node](infra::object_state const &State) { return State.saved.node == node; };
|
||||||
for (auto &s : m_history)
|
for (auto &s : m_history)
|
||||||
{
|
{
|
||||||
if (s.node_ptr == node)
|
if (s.node_ptr == node)
|
||||||
@@ -883,12 +884,14 @@ void editor_mode::nullify_history_pointers(scene::basic_node *node)
|
|||||||
if (copy.model == node)
|
if (copy.model == node)
|
||||||
copy.model = nullptr;
|
copy.model = nullptr;
|
||||||
}
|
}
|
||||||
|
s.infra.erase(std::remove_if(s.infra.begin(), s.infra.end(), followed), s.infra.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &s : g_redo)
|
for (auto &s : g_redo)
|
||||||
{
|
{
|
||||||
if (s.node_ptr == node)
|
if (s.node_ptr == node)
|
||||||
s.node_ptr = nullptr;
|
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
|
// deleted nodes also drop out of the "undo last fill" set
|
||||||
|
|||||||
Reference in New Issue
Block a user