[PATCH] Allow reading of values on invalid KConfigGroups

Thomas Braxton kde.braxton at gmail.com
Wed Feb 25 03:58:14 GMT 2009


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)




More information about the kde-core-devel mailing list