Commit 6a8cd641 authored by Sebastien Jourdain's avatar Sebastien Jourdain

Fix BUG #9287 : Server memory leak with PMObject

parent a0286cca
......@@ -106,7 +106,7 @@ vtkStandardNewMacro(vtkSMProxyManager);
vtkSMProxyManager::vtkSMProxyManager()
{
this->Session = NULL;
this->PipelineState = vtkSMPipelineState::New();
this->PipelineState = NULL;
this->UpdateInputProxies = 0;
this->Internals = new vtkSMProxyManagerInternals;
this->Observer = vtkSMProxyManagerObserver::New();
......@@ -154,7 +154,11 @@ vtkSMProxyManager::~vtkSMProxyManager()
this->WriterFactory = 0;
this->SetProxyDefinitionManager(NULL);
this->PipelineState->Delete();
if(this->PipelineState)
{
this->PipelineState->Delete();
this->PipelineState = NULL;
}
}
//----------------------------------------------------------------------------
......@@ -216,15 +220,17 @@ void vtkSMProxyManager::SetSession(vtkSMSession* session)
this->UnRegisterAllLinks();
this->UnRegisterProxies();
this->SetProxyDefinitionManager(NULL);
this->PipelineState->Delete();
this->PipelineState = NULL;
}
this->Session = session;
// This will also register the RemoteObject to the Session
this->PipelineState->SetSession(this->Session);
if (this->Session)
{
// This will also register the RemoteObject to the Session
this->PipelineState = vtkSMPipelineState::New();
this->PipelineState->SetSession(this->Session);
this->SetProxyDefinitionManager(session->GetProxyDefinitionManager());
}
}
......
......@@ -74,6 +74,33 @@ namespace
class vtkSMSessionCore::vtkInternals
{
public:
vtkInternals()
{
}
~vtkInternals()
{
// Remove PMObject left in the right order...
PMObjectMapType::iterator iter;
int nbFound, nbDelete;
nbFound = nbDelete = 1;
while(nbFound > 0)
{
nbDelete = nbFound = 0;
for(iter = this->PMObjectMap.begin();iter != this->PMObjectMap.end(); iter++)
{
vtkPMObject* obj = iter->second;
if(obj)
{
nbFound++;
if(obj->GetReferenceCount() == 1)
{
nbDelete++;
obj->Delete();
}
}
}
}
}
//---------------------------------------------------------------------------
void Delete(vtkTypeUInt32 globalUniqueId)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment