kconfig sync at exit
Matthias Kretz
kretz at kde.org
Thu Jun 21 08:22:16 BST 2007
On Wednesday 20 June 2007, Thomas Zander wrote:
> Hi,
>
> In KOffice I added a 'savePreferences()' to the destructor of my document
> class which creates a config group and writes a bunch of properties to
> it.
>
> I was surprised to see that I had to manually call 'config->sync()'
> afterwards since none of my changes (not even the new group) appeared in
> the config due to the app quitting shortly after.
if it's not crashing, then it's leaking the KConfig object, so that its dtor
never gets called.
For the KGlobal::config() there are two ways to leak it:
1.
{
KSharedConfigPtr *x = new KSharedConfigPtr(KGlobal::config());
}
2a.
{
KComponentData *x = new KComponentData(KGlobal::mainComponent());
}
or
2b.
int main()
{
KComponentData *cd = new KComponentData;
...
// no delete
}
The lifetime of the global config object and the componentdata object is the
same (i.e. they only die when both of their refcounts go to 1 - ok, that's a
bit simplified because KStandardDirs messes it up even further). That's why,
if one is leaked, the other one won't die as well.
--
________________________________________________________
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: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070621/6d4f94b5/attachment.sig>
More information about the kde-core-devel
mailing list