Generate an instance with KSharedConfig::Ptr for singleton and arg
ClosedPublic

Authored by graesslin on Nov 16 2016, 2:06 PM.

Details

Summary

In case a kcfg with arg="true" was used and singleton the static
instance method only accepted a QString config name. This made it
impossible to combine a singleton config with an already existing and
open KSharedConfig::Ptr.

With this change an overloaded instance method is added which takes a
KSharedConfig::Ptr as argument. The private ctor, though, only takes a
KSharedConfig::Ptr and the instance method taking a QString argument
uses KSharedConfig::openConfig on the config file name.

This provides full API compatibility and at the same time allows to use
KSharedConfig in addition to the arg name based variant.

Test Plan

kconfigcompiler tests still pass and a config with singleton
and arg="true" generates the code as I need it

Diff Detail

Repository
R237 KConfig
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
graesslin updated this revision to Diff 8220.Nov 16 2016, 2:06 PM
graesslin retitled this revision from to Generate an instance with KSharedConfig::Ptr for singleton and arg.
graesslin updated this object.
graesslin edited the test plan for this revision. (Show Details)
graesslin added a reviewer: Frameworks.
apol added a subscriber: apol.Nov 16 2016, 3:05 PM

How can tests still pass? they compare the generated code.

In D3386#63201, @apol wrote:

How can tests still pass? they compare the generated code.

eh no idea. I did a make clean, make, make test in the folder. Maybe there is no test for the singleton + arg="true" combination?

Just checked: the only test with a combination of arg="true" and singleton is signals_test_singleton.kcfgc which is used by kconfigcompiler_test_signals.cpp, but there is no code comparison in that test.

The only other arg="true" case is test8a.kcfg, but that one is not a singleton.

apol added a comment.Nov 16 2016, 3:38 PM

Then please include a test with your new feature.

graesslin updated this revision to Diff 8228.Nov 16 2016, 4:13 PM

Added a test case

aacid added a subscriber: aacid.Nov 30 2016, 10:56 PM

Is this another patch that doesn't say to which repository it applies? Or am i just too stupid to find it in phabricator?

ltoscano set the repository for this revision to R237 KConfig.Nov 30 2016, 11:13 PM
ltoscano added a subscriber: ltoscano.

Created and added the KConfig repository.

mdawson accepted this revision.Dec 1 2016, 10:57 PM
mdawson edited edge metadata.

LGTM!

This revision is now accepted and ready to land.Dec 1 2016, 10:57 PM
This revision was automatically updated to reflect the committed changes.