shared lib: conversion-lib in Plasma

Petri Damstén petri.damsten at gmail.com
Tue Jul 28 14:24:31 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[1], 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.

Committed changes:
* KSharedPtr is used for storing units
* Converter is not singleton anymore and has ref counted static member for 
data.
* convertTo added to Value

Petri
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20090728/1dc1b690/attachment.sig>


More information about the kde-core-devel mailing list