From 90d546d1e7d99a3f2a6594a23bfe73ca2a9d8d51 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 19 Mar 2022 15:37:31 +0100 Subject: [PATCH] Fem: replace raw pointer with WeakPtrT to check if the object has been deleted, fix crash in destructor of TaskFemConstraintOnBoundary --- src/Mod/Fem/Gui/TaskFemConstraint.h | 5 +++-- src/Mod/Fem/Gui/TaskFemConstraintOnBoundary.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Mod/Fem/Gui/TaskFemConstraint.h b/src/Mod/Fem/Gui/TaskFemConstraint.h index 2dab3c55d0..2474347fbe 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraint.h +++ b/src/Mod/Fem/Gui/TaskFemConstraint.h @@ -25,9 +25,10 @@ #ifndef GUI_TASKVIEW_TaskFemConstraint_H #define GUI_TASKVIEW_TaskFemConstraint_H -#include +#include #include #include +#include #include "ViewProviderFemConstraint.h" @@ -69,7 +70,7 @@ protected: protected: QWidget* proxy; QAction* deleteAction; - ViewProviderFemConstraint *ConstraintView; + Gui::WeakPtrT ConstraintView; enum {seldir, selref, selloc, selnone} selectionMode; private: diff --git a/src/Mod/Fem/Gui/TaskFemConstraintOnBoundary.cpp b/src/Mod/Fem/Gui/TaskFemConstraintOnBoundary.cpp index b85f91db73..a57fca6e4b 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintOnBoundary.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintOnBoundary.cpp @@ -39,7 +39,8 @@ TaskFemConstraintOnBoundary::TaskFemConstraintOnBoundary(ViewProviderFemConstrai TaskFemConstraintOnBoundary::~TaskFemConstraintOnBoundary() { - ConstraintView->highlightReferences(false); + if (!ConstraintView.expired()) + ConstraintView->highlightReferences(false); } void TaskFemConstraintOnBoundary::_addToSelection(bool checked)