setupGui strange interaction with KConfig

Ingo Klöcker kloecker at kde.org
Sun Jan 23 16:10:16 GMT 2005


On Sunday 23 January 2005 15:30, Tobias Koenig wrote:
> On Sun, Jan 23, 2005 at 01:05:15PM +0100, Albert Astals Cid wrote:
> > Hi,
>
> Hi Albert,
>
> > look at this test, calling setupGui changes the group of the
> > KInstance KConfig object. That is causing, for example bug
> > http://bugs.kde.org/show_bug.cgi?id=97229 so i don't know if it may
> > be causing any bug more.
>
> I had a similar bug in ksysguard as well some years ago... the
> problem was, that KMainWindow::applyMainWindowSettings() set a new
> group without restoring it. That's fixed in CVS HEAD now.
>
> BTW, I know KConfigGroup should be used instead of KConfigGroupSaver,
> but KConfigGroup is designed in the wrong way IMHO.
>
> I'd would expect to do the following
>
> void foorbar( KConfig *config )
> {
>   KConfigGroup group( config, "myGroup" );
>
>   readValue( &group, "MyKey" );
> }
>
> The problem is, that most methods like 'readValue' expect a KConfig*
> and not a KConfigBase*, so you can't really use KConfigGroup in real
> life...

Correct usage is
  myKey = group.readValue( "MyKey" );
which IMO makes much more sense than what you expect. After all we use 
C++ and not C.

Regards,
Ingo
-------------- 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/20050123/02aad950/attachment.sig>


More information about the kde-core-devel mailing list