From bde02d66656135072d92cd9e09dbb941b87ecea5 Mon Sep 17 00:00:00 2001 From: captain0xff Date: Sat, 20 Sep 2025 15:31:27 +0530 Subject: [PATCH] Gui: fix a lifetime issue with the draggers --- src/Gui/Inventor/Draggers/Gizmo.cpp | 6 ++++-- src/Gui/Inventor/Draggers/Gizmo.h | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Gui/Inventor/Draggers/Gizmo.cpp b/src/Gui/Inventor/Draggers/Gizmo.cpp index 67187c2ea4..82702d03c7 100644 --- a/src/Gui/Inventor/Draggers/Gizmo.cpp +++ b/src/Gui/Inventor/Draggers/Gizmo.cpp @@ -613,7 +613,7 @@ void GizmoContainer::initClass() SO_KIT_INIT_CLASS(GizmoContainer, SoBaseKit, "BaseKit"); } -GizmoContainer::GizmoContainer() +GizmoContainer::GizmoContainer(): viewProvider(nullptr) { SO_KIT_CONSTRUCTOR(GizmoContainer); @@ -655,7 +655,9 @@ GizmoContainer::~GizmoContainer() uninitGizmos(); - viewProvider->setGizmoContainer(nullptr); + if (!viewProvider.expired()) { + viewProvider->setGizmoContainer(nullptr); + } } void GizmoContainer::initGizmos() diff --git a/src/Gui/Inventor/Draggers/Gizmo.h b/src/Gui/Inventor/Draggers/Gizmo.h index b97f6f7475..c470b52296 100644 --- a/src/Gui/Inventor/Draggers/Gizmo.h +++ b/src/Gui/Inventor/Draggers/Gizmo.h @@ -35,6 +35,7 @@ #include #include +#include #include @@ -245,7 +246,7 @@ private: std::vector gizmos; SoFieldSensor cameraSensor; SoFieldSensor cameraPositionSensor; - ViewProviderDragger* viewProvider = nullptr; + WeakPtrT viewProvider; void addGizmo(Gizmo* gizmo);