KConfigSkeleton and writing defaults..

Aaron J. Seigo aseigo at kde.org
Thu Sep 18 08:08:02 BST 2008


On Wednesday 17 September 2008, Aaron J. Seigo wrote:
> hi..
>
> in the KConfigSkeletonItem class's writeConfig methods, there is this code:
>
>     if ((mDefault == mReference) && !cg.hasDefault( mKey))
>        cg.revertToDefault( mKey );
>
> this doesn't seem to make much sense to me because KConfigGroup::hasDefault
> returns false only if there is no default ... so revertToDefault when
> !hasDefault is the same as setting the item to nothing.

i think i figured out what it's trying to do: if the value of the item is the 
default value, then write it to the config file but only if there is a default 
already in the file ... otherwise null it out because the default is kept in 
the KConfigSkeletonItem.

so if there is a default value in the config file, then it will always be 
overwritten by the value on the skeleton item; if there is no default value in 
the file, only when the value of the item is not the item default will it get 
written to the file.

of course, when the config file is not accessed with the KConfigSkeleton object, 
then the defaults (and the keys when there is no default in the file) are not 
accessible (e.g. via KConfigGroup).

i'm still not sure what code relies on this behaviour, if any, and if there 
are any useful ramifications of not writing out the defaults as defined in the 
KConfigSkeleton object .... =/

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Trolltech

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


More information about the kde-core-devel mailing list