SmartPointerList

Mark Kretschmann kretschmann at kde.org
Mon Jan 11 09:41:47 GMT 2010


Hey all,

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


PS:
We're aware that the name "SmartPointerList" is a bit misleading. It's
not a list for smart pointers, but a smart list storing pointers. It
could be renamed if someone finds a better name.


-- 
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