Remove color bar from SoFCColorBarNotifier to decrease reference counter

This commit is contained in:
wmayer
2024-07-10 22:41:41 +02:00
committed by Yorik van Havre
parent d4cd9a396a
commit cf46809efd
6 changed files with 32 additions and 18 deletions

View File

@@ -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;
}

View File

@@ -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};

View File

@@ -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;
}

View File

@@ -94,8 +94,9 @@ private:
void setupNormals(const std::vector<Base::Vector3f>&);
void setupLineIndexes(const std::vector<Data::ComplexGeoData::Line>&);
void setupFaceIndexes(const std::vector<Data::ComplexGeoData::Facet>&);
void deleteColorBar();
protected:
private:
SoMaterial* pcColorMat;
SoMaterialBinding* pcMatBinding;
SoGroup* pcLinkRoot;

View File

@@ -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<Mesh::Curvature*>(pcObject)
->Source.touch(); // make sure to recompute the feature
// make sure to recompute the feature
static_cast<Mesh::Curvature*>(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;
}

View File

@@ -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: