KDE/kdelibs/kdecore/tests

David Faure faure at kde.org
Thu Oct 4 23:50:45 BST 2007


On Friday 05 October 2007, Clarence Dang wrote:
> On Friday 05 October 2007 3:29 am, David Faure wrote:
> > Today's quizz: KConfigGroup(c,"").group() == ?
> >
> > Answered by this unit test: it's "<default>", i.e. the toplevel entries in
> > the config files. I thought we had support for the empty group ("[]" in the
> > config file) but obviously not. 
> 
> The empty group did work for me, even though I considered that a bug (and it 
> didn't output any group header like "[]").

Well if it didn't output any group header then it was indeed the "toplevel group"
which is accessible via KConfigGroup(c,"") or KConfigGroup(c,"<default>") (both work).

I thought we could do [], but that was wrong (both in kde3 and kde4).

> > Good I guess, one less thing to support. 
> > But then we could get rid of the "<default>" string altogether, and use the
> > empty string instead, no?
> 
> Yes because KRecentFilesAction depends on it and was broken because 
> of "<default>":
> 
> void KRecentFilesAction::loadEntries( const KConfigGroup& _config)
> [...]
>     KConfigGroup cg = _config;
>     if ( cg.group().isEmpty())
>         cg = KConfigGroup(cg.config(), "RecentFiles");
Hmm, yes that's broken.

Note that setGroup("") (or no call to setGroup at all) also gave group() == "<default>" in KDE3, 
there is nothing new here, but the kde4 porting to KConfigGroup triggered this 
in more places than before, like in the above case (which was most probably just a setGroup
call in kde3, not a test on the current group name).

Is there any objection against using empty string instead of "<default>"? Should be a simple
search/replace over kde, and then code like the above loadEntries would work, and it would
be a bit less hidden magic.

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list