From 01623514aa36662632e126bd8283fa91a2cceaa1 Mon Sep 17 00:00:00 2001 From: Evgeny Prikazchikov Date: Tue, 21 Jul 2026 13:57:10 +0300 Subject: [PATCH 1/2] Engine: Unload of scene leads to crash #1379 --- engine/includes/components/component.h | 2 +- engine/includes/components/scene.h | 1 + engine/src/components/component.cpp | 2 +- engine/src/components/scene.cpp | 12 ++++++++++++ engine/src/components/transform.cpp | 9 ++++++--- .../src/screens/scenecomposer/objectcontroller.cpp | 5 ++--- 6 files changed, 23 insertions(+), 8 deletions(-) diff --git a/engine/includes/components/component.h b/engine/includes/components/component.h index f7be1d132..49b648a80 100644 --- a/engine/includes/components/component.h +++ b/engine/includes/components/component.h @@ -68,7 +68,7 @@ class ENGINE_EXPORT Component : public Object { bool hasTag(const TString &tag); bool hasTagByHash(uint32_t hash); - const std::vector &tags() const; + std::vector &tags(); virtual void composeComponent(); diff --git a/engine/includes/components/scene.h b/engine/includes/components/scene.h index c51df0caf..037dfbb18 100644 --- a/engine/includes/components/scene.h +++ b/engine/includes/components/scene.h @@ -20,6 +20,7 @@ class ENGINE_EXPORT Scene : public Object { public: Scene(); Scene(const Scene &origin); + ~Scene(); World *world() const; diff --git a/engine/src/components/component.cpp b/engine/src/components/component.cpp index d96f5907e..97f03bce7 100644 --- a/engine/src/components/component.cpp +++ b/engine/src/components/component.cpp @@ -191,7 +191,7 @@ bool Component::hasTagByHash(uint32_t hash) { /*! Returns list of component tags. */ -const std::vector &Component::tags() const { +std::vector &Component::tags() { return m_tags; } /*! diff --git a/engine/src/components/scene.cpp b/engine/src/components/scene.cpp index 4fda548f7..64256c6d6 100644 --- a/engine/src/components/scene.cpp +++ b/engine/src/components/scene.cpp @@ -1,6 +1,7 @@ #include "components/scene.h" #include "components/world.h" +#include "components/component.h" /*! \class Scene @@ -21,6 +22,17 @@ Scene::Scene(const Scene &origin) : m_modified(origin.m_modified) { } + +Scene::~Scene() { + for(auto &group : m_groups) { + for(auto it : group.second) { + Component *component = dynamic_cast(it); + if(component) { + component->tags().clear(); + } + } + } +} /*! Returns the World to which the scene belongs. */ diff --git a/engine/src/components/transform.cpp b/engine/src/components/transform.cpp index 37ef27133..b163a8d78 100644 --- a/engine/src/components/transform.cpp +++ b/engine/src/components/transform.cpp @@ -207,9 +207,12 @@ void Transform::setParent(Object *parent, int32_t position, bool force) { } Object::setParent(parent, 0, force); - Actor *p = dynamic_cast(actor()->parent()); - if(p) { - setParentTransform(p->transform(), true); + Actor *actor = Transform::actor(); + if(actor) { + Actor *p = dynamic_cast(actor->parent()); + if(p) { + setParentTransform(p->transform(), true); + } } } /*! diff --git a/worldeditor/src/screens/scenecomposer/objectcontroller.cpp b/worldeditor/src/screens/scenecomposer/objectcontroller.cpp index 315ab6f3e..66a0d79a1 100644 --- a/worldeditor/src/screens/scenecomposer/objectcontroller.cpp +++ b/worldeditor/src/screens/scenecomposer/objectcontroller.cpp @@ -569,7 +569,7 @@ void ObjectController::onDrop(QDropEvent *event) { for(TString &str : list) { if(!str.isEmpty()) { if(mgr->assetTypeName(str) == Map::metaClass()->name()) { - emit dropMap((ProjectSettings::instance()->contentPath() + "/" + str).data(), (event->keyboardModifiers() & Qt::ControlModifier)); + emit dropMap(str.data(), (event->keyboardModifiers() & Qt::ControlModifier)); return; } } @@ -606,9 +606,8 @@ void ObjectController::onDragEnter(QDragEnterEvent *event) { StringList list = TString(event->mimeData()->data(gMimeContent)).split(";"); AssetManager *mgr = AssetManager::instance(); - for(TString str : list) { + for(TString &str : list) { if(!str.isEmpty()) { - str = ProjectSettings::instance()->contentPath() + "/" + str; TString type = mgr->assetTypeName(str); if(type != Map::metaClass()->name()) { Actor *actor = mgr->createActor(str); From 842785872e346bc4a2747518f9959667afce8415 Mon Sep 17 00:00:00 2001 From: Evgeny Prikazchikov Date: Tue, 21 Jul 2026 14:21:07 +0300 Subject: [PATCH 2/2] update --- worldeditor/bin/editor/materials/gizmo.shader | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditor/bin/editor/materials/gizmo.shader b/worldeditor/bin/editor/materials/gizmo.shader index d82837386..28724cbb6 100644 --- a/worldeditor/bin/editor/materials/gizmo.shader +++ b/worldeditor/bin/editor/materials/gizmo.shader @@ -27,7 +27,7 @@ void main(void) { proj.y = 1.0 - proj.y; #endif float depth = getLinearDepth(texture(depthMap, proj).x, nearClipPlane(), farClipPlane()); - rgb = _color;//(depth >= _vertex.z) ? _color : vec4(_color.xyz, _color.w * 0.25); + rgb = (depth >= _vertex.z) ? _color : vec4(_color.xyz, _color.w * 0.1); } ]]>