diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp index 55aded5af5..1054626089 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp @@ -276,11 +276,16 @@ ViewProviderFemPostObject::~ViewProviderFemPostObject() m_material->unref(); m_matPlainEdges->unref(); m_switchMatEdges->unref(); + deleteColorBar(); + m_colorStyle->unref(); + m_colorRoot->unref(); +} + +void ViewProviderFemPostObject::deleteColorBar() +{ Gui::SoFCColorBarNotifier::instance().detach(m_colorBar); m_colorBar->Detach(this); m_colorBar->unref(); - m_colorStyle->unref(); - m_colorRoot->unref(); } void ViewProviderFemPostObject::attach(App::DocumentObject* pcObj) @@ -319,8 +324,7 @@ void ViewProviderFemPostObject::attach(App::DocumentObject* pcObj) pcBar->ref(); pcBar->setRange(fMin, fMax, 3); pcBar->Notify(0); - m_colorBar->Detach(this); - m_colorBar->unref(); + deleteColorBar(); m_colorBar = pcBar; } diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostObject.h b/src/Mod/Fem/Gui/ViewProviderFemPostObject.h index c70206c9b8..d86373ec79 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostObject.h +++ b/src/Mod/Fem/Gui/ViewProviderFemPostObject.h @@ -171,6 +171,7 @@ private: void WriteColorData(bool ResetColorBarRange); void WriteTransparency(); void addAbsoluteField(vtkDataSet* dset, std::string FieldName); + void deleteColorBar(); App::Enumeration m_coloringEnum, m_vectorEnum; bool m_blockPropertyChanges {false}; diff --git a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp index 17ab772a10..4dd4d784b3 100644 --- a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp +++ b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp @@ -115,9 +115,7 @@ ViewProviderInspection::~ViewProviderInspection() pcCoords->unref(); pcMatBinding->unref(); pcColorMat->unref(); - Gui::SoFCColorBarNotifier::instance().detach(pcColorBar); - pcColorBar->Detach(this); - pcColorBar->unref(); + deleteColorBar(); pcLinkRoot->unref(); pcPointStyle->unref(); } @@ -150,6 +148,13 @@ void ViewProviderInspection::show() pcColorStyle->style = SoDrawStyle::FILLED; } +void ViewProviderInspection::deleteColorBar() +{ + Gui::SoFCColorBarNotifier::instance().detach(pcColorBar); + pcColorBar->Detach(this); + pcColorBar->unref(); +} + void ViewProviderInspection::attach(App::DocumentObject* pcFeat) { // creates the standard viewing modes @@ -185,8 +190,7 @@ void ViewProviderInspection::attach(App::DocumentObject* pcFeat) pcBar->ref(); pcBar->setRange(fMin, fMax, 3); pcBar->Notify(0); - pcColorBar->Detach(this); - pcColorBar->unref(); + deleteColorBar(); pcColorBar = pcBar; } diff --git a/src/Mod/Inspection/Gui/ViewProviderInspection.h b/src/Mod/Inspection/Gui/ViewProviderInspection.h index ad7df2d015..f311da9b45 100644 --- a/src/Mod/Inspection/Gui/ViewProviderInspection.h +++ b/src/Mod/Inspection/Gui/ViewProviderInspection.h @@ -94,8 +94,9 @@ private: void setupNormals(const std::vector&); void setupLineIndexes(const std::vector&); void setupFaceIndexes(const std::vector&); + void deleteColorBar(); -protected: +private: SoMaterial* pcColorMat; SoMaterialBinding* pcMatBinding; SoGroup* pcLinkRoot; diff --git a/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp b/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp index 989a39f7db..d01d1b1068 100644 --- a/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp @@ -126,9 +126,7 @@ ViewProviderMeshCurvature::~ViewProviderMeshCurvature() { pcColorRoot->unref(); pcColorMat->unref(); - Gui::SoFCColorBarNotifier::instance().detach(pcColorBar); - pcColorBar->Detach(this); - pcColorBar->unref(); + deleteColorBar(); pcLinkRoot->unref(); } @@ -237,12 +235,19 @@ void ViewProviderMeshCurvature::slotChangedObject(const App::DocumentObject& Obj const Mesh::MeshObject& kernel = mesh.getValue(); pcColorMat->diffuseColor.setNum((int)kernel.countPoints()); pcColorMat->transparency.setNum((int)kernel.countPoints()); - static_cast(pcObject) - ->Source.touch(); // make sure to recompute the feature + // make sure to recompute the feature + static_cast(pcObject)->Source.touch(); } } } +void ViewProviderMeshCurvature::deleteColorBar() +{ + Gui::SoFCColorBarNotifier::instance().detach(pcColorBar); + pcColorBar->Detach(this); + pcColorBar->unref(); +} + void ViewProviderMeshCurvature::attach(App::DocumentObject* pcFeat) { // creates the standard viewing modes @@ -281,8 +286,7 @@ void ViewProviderMeshCurvature::attach(App::DocumentObject* pcFeat) pcBar->ref(); pcBar->setRange(fMin, fMax, 3); pcBar->Notify(0); - pcColorBar->Detach(this); - pcColorBar->unref(); + deleteColorBar(); pcColorBar = pcBar; } diff --git a/src/Mod/Mesh/Gui/ViewProviderCurvature.h b/src/Mod/Mesh/Gui/ViewProviderCurvature.h index c30fba3667..f015e4a16d 100644 --- a/src/Mod/Mesh/Gui/ViewProviderCurvature.h +++ b/src/Mod/Mesh/Gui/ViewProviderCurvature.h @@ -114,7 +114,7 @@ protected: private: void init(const Mesh::PropertyCurvatureList* prop); - + void deleteColorBar(); void slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop) override; private: