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

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