SmartPointerList

Mark Kretschmann kretschmann at kde.org
Tue Jan 12 10:49:05 GMT 2010


On Mon, Jan 11, 2010 at 11:01 AM, Thiago Macieira <thiago at kde.org> wrote:
> Em Segunda-feira 11 Janeiro 2010, às 10:41:47, Mark Kretschmann escreveu:
>> I just wanted to point you to a class that we wrote for Amarok, and
>> that we find very useful in many situations, so I was wondering if
>> there is any interest in getting it into KDElibs.
>>
>> What it does is quite simple:
>>
>> Gives you a QList for pointers (to QObjects), and if an object in it
>> is destroyed, its pointer gets removed from this list automatically.
>> We found that this can prevent a great deal of issues with dangling
>> pointers stored in lists (often a design mistake, but it can happen).
>> You be the judge if you find this class useful or not.
>>
>> You can find it here:
>>
>> http://gitorious.org/amarok/amarok/blobs/master/src/SmartPointerList.h
>> http://gitorious.org/amarok/amarok/blobs/master/src/SmartPointerList.cpp
>
> I think this was proposed before.
>
> But isn't it the same as QList<QWeakPointer<T> > ?
>
> Except that the item isn't removed from the list once it's deleted. It just
> becomes zero.

Hmm yes, I guess you are right. The thing is, back when we wrote this
class, there was no QWeakPointer (we still depended on Qt 4.4).

So maybe this is not of direct interest for KDElibs itself, but some
other applications with an independent release cycle might find it
useful.

-- 
Mark Kretschmann
Amarok Developer
Fellow of the Free Software Foundation Europe
www.kde.org - amarok.kde.org - www.fsfe.org




More information about the kde-core-devel mailing list