[interfacekit] BLooper::SetCommonFilterList() mod

  • From: "Erik Jaesler" <erik@xxxxxxxxxxxxxx>
  • To: "interface kit team" <interfacekit@xxxxxxxxxxxxx>
  • Date: Fri, 23 Aug 2002 21:03:16 -0700

Hey, all.  Thought I would ping for opinions before I did something 
rash. ;)  Currently the OBOS and R5 implementations of BLooper will 
segfault if you do this:

        BLooper Looper1;
        BLooper Looper2;
        BList* filters = new BList;
        filters->AddItem(new BMessageFilter('1234'));
        Looper1.SetCommonFilterList(filters);
        Looper2.SetCommonFilterList(filters);

The segfault happens on destruction of Looper1 because Looper2 has 
already deleted filters, leaving us with a dangling pointer.  Very bad.  
What I'd like to do is add a check on the first filter of the list to 
see if it belongs to another looper and if it does, go to debugger with 
a message like AddCommonFilter() ("A MessageFilter can only be used 
once.") and then return without setting the list.  I could check the 
whole list, but that would be more time consuming and only a real 
pervert would populate a list with filters in different states of 
ownership. ;P

Anyone see any problem with this?

Thanks,

e

Necessity is the plea for every infringement of human freedom. It is the 
argument of tyrants; it is the creed of slaves.
        -William Pitt, British prime-minister (1759-1806)


Other related posts: