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);