Skip to content
Snippets Groups Projects
Commit 69445ed5 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

better destructor
parent a25e6142
No related branches found
No related tags found
No related merge requests found
// $Id: PView.cpp,v 1.5 2007-09-01 16:05:43 geuzaine Exp $ // $Id: PView.cpp,v 1.6 2007-09-03 06:21:08 geuzaine Exp $
// //
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
// //
...@@ -73,26 +73,28 @@ PView::~PView() ...@@ -73,26 +73,28 @@ PView::~PView()
std::vector<PView*>::iterator it = std::find(list.begin(), list.end(), this); std::vector<PView*>::iterator it = std::find(list.begin(), list.end(), this);
if(it != list.end()) list.erase(it); if(it != list.end()) list.erase(it);
for(unsigned int i = 0; i < list.size(); i++) list[i]->setIndex(i);
if(!_data || _links > 0) return; if(!_data || _links > 0) return;
if(_aliasOf){ if(_aliasOf){
for(unsigned int i = 0; i < list.size(); i++){ for(unsigned int i = 0; i < list.size(); i++){
if(list[i]->getNum() == _aliasOf){ if(list[i]->getNum() == _aliasOf){
// original data still exists so we can safely delete // original data still exists, decrement ref counter
delete _data;
list[i]->getLinks()--; list[i]->getLinks()--;
return; return;
} }
} }
// original is gone for(unsigned int i = 0; i < list.size(); i++){
int numAliases = 0; if(list[i]->getAliasOf() == _aliasOf){
for(unsigned int i = 0; i < list.size(); i++) // original is gone, but other aliases exist
if(list[i]->getAliasOf() == _aliasOf) return;
numAliases++; }
if(numAliases == 1) // no others aliases so safe to delete }
delete _data;
} }
Msg(DEBUG, "Deleting data in ex-View[%d] (unique num = %d)", _index, _num);
delete _data;
} }
void PView::setChanged(bool val) void PView::setChanged(bool val)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment