Why don't the KConfig* classes have reference counting on their d-pointers, value semantics?

Matthias Kretz kretz at kde.org
Tue Apr 1 18:23:00 BST 2008


On Tuesday 01 April 2008, Thiago Macieira wrote:
> Matthias Kretz wrote:
> >Simple answer:
> >
> >KSharedConfig(Ptr) was added at some point in KDE 3 IIRC. For KDE 4 I
> > would have liked to do make KConfig a value-based, ref-counted class
> > (like KSharedConfigPtr is now), but the porting effort was too big (I
> > did make KInstance value based and that was one week full-time porting
> > work - you do that once and never again...).
>
> One solution to the problem is to create a set of wrapper classes that
> have value semantic and keep the current config classes in their
> ref-counted d-pointers.

KSharedConfigPtr basically is that class. It just has a bad name IMHO. 
KSharedConfigPtr does a little bit more, i.e.

KSharedConfigPtr a = KSharedConfig::openConfig("foo");
KSharedConfigPtr b = KSharedConfig::openConfig("foo");

makes the objects a and b reference the same KConfig object. In my experience 
this is what you want most of the time. So KSharedConfig should always be 
preferred over KConfig and accessed only using KSharedPtr.

I agree that we should try and create a more intuitve class for 
KSharedConfig(Ptr) with a better name.

suggestions for a name, so far we got
- KConfigure
I'll add
- KConfiguration
- KSettings (probably not a good idea - it doesn't extend QSettings, but 
KConfig)
- KConfig2

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- 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/20080401/38382641/attachment.sig>


More information about the kde-core-devel mailing list