shared lib: conversion-lib in Plasma
petri.damsten at gmail.com
Tue Jul 28 14:12:36 BST 2009
On Tuesday 28 July 2009 11:54:55 Aaron J. Seigo wrote:
> On Tuesday 28 July 2009, Petri Damstén wrote:
> > Which I removed, since I can't see how it could work if Unit is
> > KSharedPtr. Converter has UnitCategories which has Units. Category takes
> > care of creating and deleting units. If Unit is deleted outside category
> > (by KSharedPtr or otherwise) categories will fail. Values only have
> > pointer to unit.
> problem is that this is very brittle. it means new units can never be
> dynamically added/removed safely, but more importantly if the units are to
> be cleaned up at some point (which i think they do, as noted in the
> previous email) then handing around the same naked pointer amongst various
> classes is just asking for a dangling pointer to appear somewhere.
> since UnitCategory keeps a reference to the Unit in its two maps, if
> they were KSharedPtrs instead they'd stay in reference until the
> UnitCategory went away. the UnitCategory would then be in clear ownership
> of the Unit objects and control their life-span.
Yes you are right. I got carried a way because sharedptr was only used in
Value but yes if it's used also in categories then it should work.
>  btw, all the calls to keys() and values() in UnitCategory really ought
> to be changed to something else; both of those calls iterate through the
> collections and create a whole new collection. having a simple collection
> (e.g. a List or a Set) of KSharedPtr<Unit> would prevent all the calls to
> values, for instance.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 189 bytes
Desc: This is a digitally signed message part.
More information about the kde-core-devel