From 98ed31c5281f561161d7d75853b7d81c8fa7ede2 Mon Sep 17 00:00:00 2001 From: guigues Date: Wed, 12 Nov 2008 15:42:52 +0000 Subject: [PATCH] Nasty bug fix ! The 'global execution list' collected black box pointers (i.e. boost::shared_ptr) 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 !) --- kernel/src/bbtkBlackBox.cxx | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/kernel/src/bbtkBlackBox.cxx b/kernel/src/bbtkBlackBox.cxx index c21285c..859430f 100644 --- a/kernel/src/bbtkBlackBox.cxx +++ b/kernel/src/bbtkBlackBox.cxx @@ -2,8 +2,8 @@ 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 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -50,7 +50,7 @@ namespace bbtk static bool bbmgSomeBoxExecuting = false; static bool bbmgFreezeExecution = false; - static std::set bbmgExecutionList; + static std::set bbmgExecutionList; //========================================================================= BlackBox::Deleter::Deleter() @@ -1135,14 +1135,24 @@ namespace bbtk "=> BlackBox::bbGlobalProcessExecutionList()" <::iterator i; + std::set::iterator i; for (i=bbmgExecutionList.begin(); i!=bbmgExecutionList.end(); ++i) { - bbtkDebugMessage("process",4, - " -> Executing "<<(*i)->bbGetFullName()<bbExecute(true); + { + if ((*i).lock()) + { + bbtkDebugMessage("process",4, + " -> Executing "<< + (*i).lock()->bbGetFullName()<bbExecute(true); + } + else + { + bbtkGlobalError("Strange error in BlackBox::bbGlobalProcessExecutionList() : Weak bb pointer in bbmgExecutionList is no more valid..."); + } + } } bbmgExecutionList.clear(); -- 2.45.1