From c1980dbc51c9aa2770d09850e69529ea2211924b Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 16 Mar 2014 23:30:59 +0100 Subject: Add KCoreConfigSkeleton::read() which doesn't call reparseConfiguration. Call it from generated singletons, since the constructor creates a KConfig from a filename, which already loads from disk. This removes the need for using DelayedParsing. REVIEW: 116845 --- src/core/kcoreconfigskeleton.cpp | 7 ++++++- src/core/kcoreconfigskeleton.h | 12 ++++++++++++ src/kconfig_compiler/kconfig_compiler.cpp | 4 ++-- 3 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp index 0c1a96fa..0a9b0dfe 100644 --- a/src/core/kcoreconfigskeleton.cpp +++ b/src/core/kcoreconfigskeleton.cpp @@ -986,7 +986,7 @@ KCoreConfigSkeleton::KCoreConfigSkeleton(const QString &configname, QObject *par { //qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")"; - d->mConfig = KSharedConfig::openConfig(configname, KConfig::FullConfig | KConfig::DelayedParsing); + d->mConfig = KSharedConfig::openConfig(configname, KConfig::FullConfig); } KCoreConfigSkeleton::KCoreConfigSkeleton(KSharedConfig::Ptr pConfig, QObject *parent) @@ -1065,6 +1065,11 @@ void KCoreConfigSkeleton::readConfig() { // qDebug(); d->mConfig->reparseConfiguration(); + read(); +} + +void KCoreConfigSkeleton::read() +{ KConfigSkeletonItem::List::ConstIterator it; for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) { (*it)->readConfig(d->mConfig.data()); diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h index a2b828a4..90562f45 100644 --- a/src/core/kcoreconfigskeleton.h +++ b/src/core/kcoreconfigskeleton.h @@ -1040,6 +1040,18 @@ public: */ virtual void readConfig(); + /** + * Read preferences from the KConfig object. + * This method assumes that the KConfig object was previously loaded, + * i.e. it uses the in-memory values from KConfig without reloading from disk. + * + * This method calls usrReadConfig() after reading the settings of the + * registered items from the KConfig. You can overridde usrReadConfig() + * in derived classes if you have special requirements. + * @since 5.0 + */ + void read(); + /** * Set the config file group for subsequent addItem() calls. It is valid * until setCurrentGroup() is called with a new argument. Call this before diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index 7d84cfbc..28b151c5 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -2249,7 +2249,7 @@ int main(int argc, char **argv) } else { cpp << " if (!s_global" << cfg.className << "()->q) {" << endl; cpp << " new " << cfg.className << ';' << endl; - cpp << " s_global" << cfg.className << "()->q->readConfig();" << endl; + cpp << " s_global" << cfg.className << "()->q->read();" << endl; cpp << " }" << endl << endl; } cpp << " return s_global" << cfg.className << "()->q;" << endl; @@ -2263,7 +2263,7 @@ int main(int argc, char **argv) cpp << " return;" << endl; cpp << " }" << endl; cpp << " new " << cfg.className << "(cfgfilename);" << endl; - cpp << " s_global" << cfg.className << "()->q->readConfig();" << endl; + cpp << " s_global" << cfg.className << "()->q->read();" << endl; cpp << "}" << endl << endl; } } -- cgit v1.2.1