Here's a little class that we developed for Amarok, and I thought it might be interesting for some of you as well (maybe KDElibs?). What it does is the following:
Assume that you have a list of pointers to objects (they must be QObject subclasses). Sometimes such lists are used to cache pointers in multiple places, but the objects they contain (as pointers) might be destroyed at some point. In Amarok we had this problem with QAction: Many classes stored lists of pointers to actions, but sometimes actions were destroyed (e.g. on track change), and the lists got out of sync. You could probably see this as a design flaw, but we came up with a simple solution:
SmartPointerList is a QList for pointers which automatically removes a pointer when the object it refererences is destroyed. A simple idea (by myself), implemented with help from Ian Monroe and Max Howell (of Amarok/FileLight/DragonPlayer/Last.fm fame). In our case, it solved many ugly crashes that were pretty hard to debug.
If you feel the class could be useful to you, have a look here:
http://gitorious.org/amarok/amarok/blobs/master/src/SmartPointerList.h
http://gitorious.org/amarok/amarok/blobs/master/src/SmartPointerList.cpp
Enjoy