From 013127bab01839cb26a698da04092d86b22a599f Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Tue, 16 Jul 2024 15:35:06 +0200 Subject: [PATCH] Fix issue when removing drawable from scene by setting it's scene to nullptr --- openVulkanoCpp/Scene/Node.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openVulkanoCpp/Scene/Node.cpp b/openVulkanoCpp/Scene/Node.cpp index 8bb41c2..1ceebf1 100644 --- a/openVulkanoCpp/Scene/Node.cpp +++ b/openVulkanoCpp/Scene/Node.cpp @@ -133,10 +133,13 @@ namespace OpenVulkano::Scene } for (auto& drawable : drawables) { - Scene* drawableScene = drawable->GetScene(); - if(drawableScene && drawableScene != scene) [[unlikely]] + if (scene) { - throw std::runtime_error("Drawable is already associated with a scene! Creating copy."); + Scene* drawableScene = drawable->GetScene(); + if(drawableScene && drawableScene != scene) [[unlikely]] + { + throw std::runtime_error("Drawable is already associated with a scene! Creating copy."); + } } drawable->SetScene(scene); }