RE: The iterator interface



Hi Philip, 

>-----Original Message-----
>From: tinymail-devel-list-bounces gnome org 
>[mailto:tinymail-devel-list-bounces gnome org] On Behalf Of 
>ext Philip Van Hoof
>Sent: Sunday, August 06, 2006 18:03
>To: tinymail-devel-list gnome org
>Subject: Re: The iterator interface
>
>On Sun, 2006-08-06 at 16:56 +0200, Philip Van Hoof wrote:
>> The Python language binding discussion with James stumbled on an 
>> interesting point of discussion:
>> 
>> GObject* tny_iterator_iface_next (TnyIteratorIface *self);
>> GObject* tny_iterator_iface_prev (TnyIteratorIface *self);
>> GObject* tny_iterator_iface_first (TnyIteratorIface *self);
>> GObject* tny_iterator_iface_nth (TnyIteratorIface *self, guint nth);
>> GObject* tny_iterator_iface_current (TnyIteratorIface *self);
>> 
>> 
>> Shouldn't these methods add a reference to the returned object? If 
>> while iterating a list gets modified (for example an item gets 
>> removed) and the current item is the one that was modified 
>(removed), 
>> the current would other possibly be destroyed.
>> 
>> This would only happen in a multi-threaded situation, of course.
>> 
>> I was thinking about not letting the first four return the GObject, 
>> and letting _current add a reference. What do you guys think?

That sounds like a good plan; make 'm void. And then maybe add 
ref'ing and non-ref'ing versions of _current, maybe with a bool flag?

ie.
GObject* tny_iterator_iface_current (const TnyIteratorIface *self,
gboolean add_ref);

(adding the const as well, for good taste :-). Of course I can make the
changes,
but do you agree?

Best wishes,
Dirk.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]