From ca093646140403228266f1614f15d8a404ee1345 Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Sun, 23 Jul 2023 16:01:59 +0200 Subject: [PATCH] [Bugfix]Gui: detach field sensor of draggers and handle post-call of callbacks, fixes #9465 --- src/Gui/SoFCCSysDragger.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Gui/SoFCCSysDragger.cpp b/src/Gui/SoFCCSysDragger.cpp index 27e91c55a8..a17e39620a 100644 --- a/src/Gui/SoFCCSysDragger.cpp +++ b/src/Gui/SoFCCSysDragger.cpp @@ -128,7 +128,8 @@ TDragger::TDragger() TDragger::~TDragger() { - + fieldSensor.setData(nullptr); + fieldSensor.detach(); } void TDragger::buildFirstInstance() @@ -216,9 +217,12 @@ void TDragger::fieldSensorCB(void *f, SoSensor *) { auto sudoThis = static_cast(f); - SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft - sudoThis->workFieldsIntoTransform(matrix); - sudoThis->setMotionMatrix(matrix); + if(!f) + return; + + SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft + sudoThis->workFieldsIntoTransform(matrix); + sudoThis->setMotionMatrix(matrix); } void TDragger::valueChangedCB(void *, SoDragger *d) @@ -402,7 +406,8 @@ RDragger::RDragger() RDragger::~RDragger() { - + fieldSensor.setData(nullptr); + fieldSensor.detach(); } void RDragger::buildFirstInstance() @@ -488,9 +493,12 @@ void RDragger::fieldSensorCB(void *f, SoSensor *) { auto sudoThis = static_cast(f); - SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft - sudoThis->workFieldsIntoTransform(matrix); - sudoThis->setMotionMatrix(matrix); + if(!f) + return; + + SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft + sudoThis->workFieldsIntoTransform(matrix); + sudoThis->setMotionMatrix(matrix); } void RDragger::valueChangedCB(void *, SoDragger *d)