KConfig::addConfigSources is broken

Thomas Braxton kde.braxton at gmail.com
Mon Nov 19 13:52:07 GMT 2007


On 11/19/07, Andreas Pakulat <apaku at gmx.de> wrote:
> On 19.11.07 13:33:54, Andreas Pakulat wrote:
> > On 19.11.07 11:58:52, Andreas Pakulat wrote:
> > > On 18.11.07 22:52:05, Thomas Braxton wrote:
> > > > On 11/18/07, Andreas Pakulat <apaku at gmx.de> wrote:
> > > > > Yeah, actually I don't care which file I have to use in the openConfig()
> > > > > and which file to use in the addConfigSources as long as the symmetry is
> > > > > kept.
> > > >
> > > > I tested this, and the symmetry is still there. Try my previous
> > > > suggestion and if it still doesn't work, then we have a bug, which
> > > > I'll gladly fix. I don't see how opening one file, then expecting
> > > > writes to go to a different file is symmetrical, or sensible. But, if
> > > > that's the way you want it I can easily change it.
> > >
> > > Sorry for not testing it earlier, so I did that switch now and have:
> > >
> > > d->m_cfg = KSharedConfig::openConfig( d->developerTempFile );
> > > d->m_cfg->addConfigSources( QStringList() << d->projectTempFile );
> > >
> > > KConfigGroup projectGroup( d->m_cfg, "Project" );
> > >
> > > QString managerSetting = projectGroup.readEntry( "Manager", "KDevGenericManager" );
> > >
> > > And projectTempFile contains the Project group with an entry for
> > > "Manager" thats not "KDevGenericManager"
> > >
> > > When I now start KDevelop and let it load the project, I get a happily
> > > cycling KDevelop at 90% CPU, because its using the KDevGenericManager
> > > and not the Manager plugin that is stated in the projectTempFile.
> >
> > I did some testing with a simple App (generated from kapptemplate) and I
> > think these are the problems when using the way Thomas suggested:
> >
> > - readEntry only reads from the file that the config was created (i.e.
> >   the one given to openConfig.
> >   Reading an entry that is in both files returns the value from the file
> >   that the config was created with, reading an entry that only exists in
> >   the file that was added, results in getting the default value given to
> >   readEntry()
> >
> > - writing out a new group doesn't work at all, using
> >     KConfigGroup newgrp( cfg, "NewGroup" );
> >     grp.writeEntry( "NewEntry", "NewValue");
> >     grp.sync();
> >     cfg->sync();
> >
> >   doesn't create a new group in the file that the config was opened
> >   with.
> >
> > The code I added to the app (in the KMainWindow subclass constructor)
> > is:
>
> Bah, I shouldn't code when I'm in a hurry. Of course the second point is
> due to a coding error on my side. So only reading from a config object
> is a problem.
>
Try calling reparseConfiguration after addConfigSources, without it
the files added are never parsed. You should have needed this before
the merge, because I'm not seeing where the files are parsed
automatically.




More information about the kde-core-devel mailing list