This is a multi-part message in MIME format. ------=_NextPart_000_013C_01C7E5F3.3EC4B180 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello I'm trying to make KLocale independent form KConfigINIBackend internals. This is the first patch out of two to reach this goal. This shouldn't break anything, but I heard some bad stories about KLocale, so I wanted to ask before committing. I will remove the doFormatInit function before committing. PutHuhn ------=_NextPart_000_013C_01C7E5F3.3EC4B180 Content-Type: text/x-patch; name="klocale.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="klocale.patch" Index: klocale.cpp =================================================================== --- klocale.cpp (revision 704027) +++ klocale.cpp (working copy) @@ -110,7 +110,7 @@ /** * @internal Reads the format configuration from disk. */ - void initFormat(KLocale *parent); + void initFormat(KConfig *config); /** * @internal The worker of the same-name KLocale API function. @@ -199,7 +199,7 @@ // Misc QString encoding; QTextCodec * codecForEncoding; - KSharedConfig::Ptr config; + //KSharedConfig::Ptr config; int pageSize; KLocale::MeasureSystem measureSystem; KConfigBase * languages; @@ -221,7 +221,7 @@ KLocale::KLocale( const QString & catalog, KSharedConfig::Ptr config ) : d(new KLocalePrivate) { - d->config = config; +// d->config = config; d->languages = 0; d->calendar = 0; d->formatInited = false; @@ -229,17 +229,19 @@ d->initEncoding(0); d->initFileNameEncoding(0); - KSharedConfig::Ptr cfg = d->config; + KSharedConfig::Ptr cfg = config; this_klocale = this; if (!cfg) cfg = KGlobal::config(); this_klocale = 0; - Q_ASSERT( cfg ); + Q_ASSERT( cfg ); d->appName = catalog; d->initLanguageList(cfg.data(), !config); d->initMainCatalogs(catalog); d->useTranscript = false; + + d->initFormat(cfg.data()); } QString KLocale::_initLanguage(KConfigBase *config) @@ -347,28 +349,20 @@ void KLocalePrivate::doFormatInit(const KLocale *parent) { +/* to be removed if ( formatInited ) return; initFormat(const_cast(parent)); - formatInited = true; + formatInited = true;*/ } -void KLocalePrivate::initFormat(KLocale *parent) +void KLocalePrivate::initFormat(KConfig *config) { - if (!config) { - config = KGlobal::config(); - } - Q_ASSERT(config); + Q_ASSERT(config); - kDebug(173) << "KLocale::initFormat"; + kDebug(173) << "KLocalePrivate::KLocalePrivate"; - // make sure the config files are read using the correct locale - // ### Why not add a KConfigBase::setLocale( const KLocale * )? - // ### Then we could remove this hack - KLocale *lsave = KGlobal::locale(); - KGlobal::setLocale(parent); - KConfigGroup cg(config, "Locale"); KConfig entryFile(KStandardDirs::locate("locale", @@ -441,9 +435,6 @@ read3ConfigBoolEntry("NounDeclension", false, nounDeclension); read3ConfigBoolEntry("DateMonthNamePossessive", false, dateMonthNamePossessive); - - // end of hack - KGlobal::setLocale(lsave); } bool KLocale::setCountry(const QString & aCountry) ------=_NextPart_000_013C_01C7E5F3.3EC4B180--