Use of const arg in KConfigGroup constructors doesn't work with language bindings

Richard Dale rdale at foton.es
Tue Mar 4 20:09:52 GMT 2008


I've had a problem with these two pairs of constructors in kconfiggroup.h:

    KConfigGroup(KConfigBase *master, const QString &group);
    KConfigGroup(KConfigBase *master, const char *group);

     KConfigGroup(const KConfigBase *master, const QString &group);
    KConfigGroup(const KConfigBase *master, const char *group);

They only differ by the const-ness of the first argument, and this is 
impossible to get working with any other language than c++. I would prefer an 
enum to be passed, like KConfigBase::AccessType to specify whether or not the 
KConfigGroup can be written too. I've worked round the problem by just 
ignoring the read-only const method calls, and so bindings will always get a 
writable KConfigGroup.

A comment in the header says this:

    /**
     * Construct a read-only config group. A read-only group will silently 
ignore
     * any attempts to write to it.
...

I think something like this is clearer and less error prone:

    KConfigGroup(KConfigBase *master, const QString &group, AccessType mode = 
ReadOnly);
    KConfigGroup(KConfigBase *master, const char *group, AccessType mode = 
ReadOnly);

-- Richard





More information about the kde-core-devel mailing list