[PATCH] Allow reading of values on invalid KConfigGroups

Sebastian Trüg trueg at kde.org
Wed Feb 25 08:41:27 GMT 2009


On Wednesday 25 February 2009 04:58:14 Thomas Braxton wrote:
> On 2/24/09, Sebastian Trüg <sebastian at trueg.de> wrote:
> > On Tuesday 24 February 2009 15:08:34 Thomas Braxton wrote:
> >> I don't know why you would want to read from an invalid group, but
> >> wouldn't it make the patch a lot easier if you just returned the
> >> default right away if the group is invalid? i.e.
> >>
> >> replace
> >>     Q_ASSERT(isValid());
> >> with
> >>     if (!isValid()) {
> >>         return aDefault;
> >>     }
> >
> > yes, I just like one-exit-point methods better. But I don't really care.
> > :)
>
> I think I finally figured out what you're trying to do, and it's
> already supported in KConfig. You can have an "anonymous" config
> object. I think using that feature of KConfig would be better than
> working with invalid groups, because KConfigGroup is meant to be used
> only as a part of a config object. I don't think I documented how to
> open an anonymous object, so here it is; KConfig(QString(),
> KConfig::SimpleConfig)

aha! Great. Then my commit is really not necessary. Could you please add that 
to the documentation?

Cheers,
Sebastian




More information about the kde-core-devel mailing list