Ensure Elements don't unlink from an already dead Scene

This commit is contained in:
Jonas Kulla 2013-09-30 19:30:05 +02:00
parent 9d34fc966b
commit 05f73f0b98
2 changed files with 14 additions and 2 deletions

View File

@ -30,6 +30,17 @@ Scene::Scene()
geometry.rect = IntRect(); geometry.rect = IntRect();
} }
Scene::~Scene()
{
/* Ensure elements don't unlink from a destructed Scene */
IntruListLink<SceneElement> *iter;
for (iter = elements.begin(); iter != elements.end(); iter = iter->next)
{
iter->data->scene = 0;
}
}
void Scene::insert(SceneElement &element) void Scene::insert(SceneElement &element)
{ {
IntruListLink<SceneElement> *iter; IntruListLink<SceneElement> *iter;
@ -162,5 +173,6 @@ bool SceneElement::operator<(const SceneElement &o) const
void SceneElement::unlink() void SceneElement::unlink()
{ {
scene->elements.remove(link); if (scene)
scene->elements.remove(link);
} }

View File

@ -42,7 +42,7 @@ public:
}; };
Scene(); Scene();
virtual ~Scene() {} virtual ~Scene();
virtual void composite(); virtual void composite();
virtual void requestViewportRender(Vec4& /*color*/, Vec4& /*flash*/, Vec4& /*tone*/) {} virtual void requestViewportRender(Vec4& /*color*/, Vec4& /*flash*/, Vec4& /*tone*/) {}