bug: flecs::world move constructor doesn't "steal" from passed in world causing double destruction
@@ -680,6 +680,9 @@ public:
world(world&& obj) {
m_world = obj.m_world;
+ m_owned = obj.m_owned;
+ obj.m_world = nullptr;
+ obj.m_owned = false;
}
/** Not allowed to copy a world. May only take a reference.
@@ -687,12 +690,17 @@ public:
world& operator=(const world& obj) = delete;
world& operator=(world&& obj) {
+ this->~world();
+
m_world = obj.m_world;
+ m_owned = obj.m_owned;
+ obj.m_world = nullptr;
+ obj.m_owned = false;
return *this;
}
~world() {
- if (m_owned) {
+ if (m_owned && m_world) {
ecs_fini(m_world);
}
}
