summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--editor/imgui.cpp3
-rw-r--r--editor/scenery-editor.cpp10
-rw-r--r--editor/vobj-editor.cpp12
-rw-r--r--src/chunk.cpp1
4 files changed, 15 insertions, 11 deletions
diff --git a/editor/imgui.cpp b/editor/imgui.cpp
index 2923c3ea..4fadfe44 100644
--- a/editor/imgui.cpp
+++ b/editor/imgui.cpp
@@ -338,7 +338,7 @@ void app::do_popup_menu()
{
const auto [id, target] = _popup_target;
auto& w = M->world();
- const auto eʹ = w.find_object(id);
+ auto eʹ = w.find_object(id);
if (target == popup_target_type::none || !eʹ)
{
@@ -394,6 +394,7 @@ void app::do_popup_menu()
e.chunk().remove_object(e.index());
e.destroy_script_post();
e.gone = true;
+ eʹ.destroy();
}
}
else
diff --git a/editor/scenery-editor.cpp b/editor/scenery-editor.cpp
index 778a0275..4de14207 100644
--- a/editor/scenery-editor.cpp
+++ b/editor/scenery-editor.cpp
@@ -93,12 +93,14 @@ start:
while (auto id = a.get_object_colliding_with_cursor())
{
for (auto i = 0uz; i < sz; i++)
- if (const auto eʹ = es[i]; eʹ->id == id)
+ if (auto eʹ = es[i]; eʹ->id == id)
{
- eʹ->destroy_script_pre(eʹ, script_destroy_reason::kill);
+ auto& e = *eʹ;
+ e.destroy_script_pre(eʹ, script_destroy_reason::kill);
c.remove_object(i);
- eʹ->destroy_script_post();
- eʹ->gone = true;
+ e.destroy_script_post();
+ e.gone = true;
+ eʹ.destroy();
goto start;
}
break;
diff --git a/editor/vobj-editor.cpp b/editor/vobj-editor.cpp
index c95af843..4c2828e1 100644
--- a/editor/vobj-editor.cpp
+++ b/editor/vobj-editor.cpp
@@ -54,13 +54,15 @@ start:
{
for (auto i = (int)(es.size()-1); i >= 0; i--)
{
- const auto eʹ = es[i];
- if (eʹ->id == id && eʹ->is_virtual())
+ auto eʹ = es[i];
+ auto& e = *eʹ;
+ if (e.id == id && eʹ->is_virtual())
{
- eʹ->destroy_script_pre(eʹ, script_destroy_reason::kill);
+ e.destroy_script_pre(eʹ, script_destroy_reason::kill);
c.remove_object((unsigned)i);
- eʹ->destroy_script_post();
- eʹ->gone = true;
+ e.destroy_script_post();
+ e.gone = true;
+ eʹ.destroy();
goto start;
}
}
diff --git a/src/chunk.cpp b/src/chunk.cpp
index 0cb42ef6..6ccf3d27 100644
--- a/src/chunk.cpp
+++ b/src/chunk.cpp
@@ -196,7 +196,6 @@ void chunk::remove_object(size_t i)
}
arrayRemove(_objects, i);
- //eʹ.destroy();
}
ArrayView<const bptr<object>> chunk::objects() const