The 'global execution list' collected black box pointers (i.e. boost::shared_ptr<BlackBox*>) and if it was not reprocessed and thus cleared before exit then BlackBoxes might not be automatically deleted (ref count still > 0). Changed the pointers with weak pointers and correctly checked that they are still valid before using them.
This fixed very nasty bugs in which commands like 'connect A.BoxChange B.BoxExecute' for WxBlackBoxes created apparently random leaks on exit (depending on the order the windows were closed or if they were touched !)
Program: bbtk
Module: $RCSfile: bbtkBlackBox.cxx,v $
Language: C++
Program: bbtk
Module: $RCSfile: bbtkBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/10/17 08:18:12 $
- Version: $Revision: 1.25 $
+ Date: $Date: 2008/11/12 15:42:52 $
+ Version: $Revision: 1.26 $
=========================================================================*/
/* ---------------------------------------------------------------------
=========================================================================*/
/* ---------------------------------------------------------------------
static bool bbmgSomeBoxExecuting = false;
static bool bbmgFreezeExecution = false;
static bool bbmgSomeBoxExecuting = false;
static bool bbmgFreezeExecution = false;
- static std::set<BlackBox::Pointer> bbmgExecutionList;
+ static std::set<BlackBox::WeakPointer> bbmgExecutionList;
//=========================================================================
BlackBox::Deleter::Deleter()
//=========================================================================
BlackBox::Deleter::Deleter()
"=> BlackBox::bbGlobalProcessExecutionList()"
<<std::endl);
"=> BlackBox::bbGlobalProcessExecutionList()"
<<std::endl);
- std::set<BlackBox::Pointer>::iterator i;
+ std::set<BlackBox::WeakPointer>::iterator i;
for (i=bbmgExecutionList.begin();
i!=bbmgExecutionList.end();
++i)
{
for (i=bbmgExecutionList.begin();
i!=bbmgExecutionList.end();
++i)
{
- bbtkDebugMessage("process",4,
- " -> Executing "<<(*i)->bbGetFullName()<<std::endl);
- (*i)->bbExecute(true);
+ {
+ if ((*i).lock())
+ {
+ bbtkDebugMessage("process",4,
+ " -> Executing "<<
+ (*i).lock()->bbGetFullName()<<std::endl);
+ (*i).lock()->bbExecute(true);
+ }
+ else
+ {
+ bbtkGlobalError("Strange error in BlackBox::bbGlobalProcessExecutionList() : Weak bb pointer in bbmgExecutionList is no more valid...");
+ }
+ }
}
bbmgExecutionList.clear();
}
bbmgExecutionList.clear();