[interfacekit] Re: AW: Back in the saddle!

>Well, I'll take the BList using the void pointers for the BListView. 
Concerning the
>NULL pointers - if you add a NULL pointer or a list of NULL pointers to 
the List
>it will crash the program (if you use the original BListView) because 
it needs to
>update the list view.

Yes, this is definitely a Bad Thing (TM); let's fix.

>There are two possibilities:
>1. check each item if it is really an object derived from BListItem 
before
>accessing it.

You can only check on the object's type in the AddItem() functions -- as 
you point out, in the AddList()s they're already void*s -- and since the 
programmer would have to be deliberately casting something that isn't 
derived from BListItem just to get his app to build, I think it's safe 
to simply check for NULL and return false if it is.  We should protect 
from programmer mistakes where we can, but there's not much we can do 
against willful stupidity. ;)

Having given it a bit more thought, in R2 I'd like to a new pair of 
AddList() functions which take BObjectList<BListItem*> as the parameter, 
perhaps even deprecating the original functions.  In fact, I think it's 
worth considering using BObjectList internally right now, and simply 
copying data from the incoming BList parameter.

It's funny; I went looking at ObjectList.h in the Open Tracker 
repository and saw the whole "Danger, Will Robinson" warning at the top 
of the file and thought "Oh, guess we can't really use that" before 
realizing *we* (openbeos) are now the arbitrators of what is and isn't 
public API. ;P

e

Our chief want is someone who will inspire us to be what we know we 
could be.
        - Ralph Waldo Emerson, writer and philosopher (1803-1882)


Other related posts: