[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdecore/localization
From: David Faure <faure () kde ! org>
Date: 2009-10-02 15:40:30
Message-ID: 1254498030.867404.5940.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1030572 by dfaure:
Use the -same- mutex for KLocale and KLocalizedString, since they both call each \
other.
M +17 -15 klocale.cpp
A klocale_p.h [License: UNKNOWN]
M +11 -13 klocalizedstring.cpp
--- trunk/KDE/kdelibs/kdecore/localization/klocale.cpp #1030571:1030572
@@ -22,6 +22,7 @@
*/
#include "klocale.h"
+#include "klocale_p.h"
#include <config.h>
@@ -247,7 +248,6 @@
// Handling of translation catalogs
QStringList languageList;
- QMutex* mutex;
QList<KCatalogName> catalogNames; // list of all catalogs (regardless of language)
QList<KCatalog> catalogs; // list of all found catalogs, one instance per catalog \
name and language int numberOfSysCatalogs; // number of catalogs that each app draws \
from @@ -278,7 +278,6 @@
KLocalePrivate::KLocalePrivate(const QString& catalog, KConfig *config, const \
QString &language_, const QString &country_) : language(language_),
country(country_),
- mutex(new QMutex(QMutex::Recursive)),
useTranscript(false),
codecForEncoding(0),
languages(0), calendar(0),
@@ -313,7 +312,7 @@
void KLocalePrivate::initMainCatalogs()
{
KLocaleStaticData *s = staticData;
- QMutexLocker lock(mutex);
+ QMutexLocker lock(kLocaleMutex());
if (!s->maincatalog.isEmpty()) {
// If setMainCatalog was called, then we use that (e.g. korgac calls \
setMainCatalog("korganizer") to use korganizer.po) @@ -536,7 +535,7 @@
bool KLocalePrivate::setLanguage(const QString & _language, KConfig *config)
{
- QMutexLocker lock(mutex);
+ QMutexLocker lock(kLocaleMutex());
languageList.removeAll( _language );
languageList.prepend( _language ); // let us consider this language to be the most \
important one
@@ -558,7 +557,7 @@
bool KLocalePrivate::setLanguage(const QStringList & languages)
{
- QMutexLocker lock(mutex);
+ QMutexLocker lock(kLocaleMutex());
// This list might contain
// 1) some empty strings that we have to eliminate
// 2) duplicate entries like in de:fr:de, where we have to keep the first \
occurrence of a language in order @@ -680,7 +679,7 @@
void KLocale::insertCatalog( const QString & catalog )
{
- QMutexLocker lock(d->mutex);
+ QMutexLocker lock(kLocaleMutex());
int pos = d->catalogNames.indexOf(KCatalogName(catalog));
if (pos != -1) {
++d->catalogNames[pos].loadCount;
@@ -731,7 +730,7 @@
void KLocale::removeCatalog(const QString &catalog)
{
- QMutexLocker lock(d->mutex);
+ QMutexLocker lock(kLocaleMutex());
int pos = d->catalogNames.indexOf(KCatalogName(catalog));
if (pos == -1)
return;
@@ -744,7 +743,7 @@
void KLocale::setActiveCatalog(const QString &catalog)
{
- QMutexLocker lock(d->mutex);
+ QMutexLocker lock(kLocaleMutex());
int pos = d->catalogNames.indexOf(KCatalogName(catalog));
if (pos == -1)
return;
@@ -754,7 +753,6 @@
KLocale::~KLocale()
{
- delete d->mutex;
delete d->calendar;
delete d->languages;
delete d;
@@ -783,7 +781,7 @@
<< "Fix the program" << endl;
}
- QMutexLocker locker(mutex);
+ QMutexLocker locker(kLocaleMutex());
// determine the fallback string
QString fallback;
if ( msgid_plural == NULL )
@@ -1451,7 +1449,7 @@
if (dialect == d->binaryUnitDialect) {
// Cache default units for speed
if (d->byteSizeFmt.size() == 0) {
- QMutexLocker lock(d->mutex);
+ QMutexLocker lock(kLocaleMutex());
// We only cache the user's default dialect.
d->byteSizeFmt = d->dialectUnitsList(d->binaryUnitDialect);
@@ -1507,7 +1505,7 @@
void KLocale::setBinaryUnitDialect(BinaryUnitDialect newDialect)
{
- QMutexLocker lock(d->mutex);
+ QMutexLocker lock(kLocaleMutex());
d->binaryUnitDialect = newDialect;
d->byteSizeFmt.clear(); // Reset cached translations.
@@ -2570,7 +2568,6 @@
{
d->languages = 0; // Don't copy languages
d->calendar = 0; // Don't copy the calendar
- d->mutex = 0; // Don't copy the mutex
}
KLocale & KLocale::operator=(const KLocale & rhs)
@@ -2585,8 +2582,7 @@
void KLocale::copyCatalogsTo(KLocale *locale)
{
- QMutexLocker lock(d->mutex);
- QMutexLocker lockOther(locale->d->mutex);
+ QMutexLocker lock(kLocaleMutex());
locale->d->catalogNames = d->catalogNames;
locale->d->updateCatalogs();
}
@@ -2658,3 +2654,9 @@
{
return d->dateTimeDigitSet;
}
+
+Q_GLOBAL_STATIC_WITH_ARGS(QMutex, s_kLocaleMutex, (QMutex::Recursive))
+QMutex* kLocaleMutex()
+{
+ return s_kLocaleMutex();
+}
--- trunk/KDE/kdelibs/kdecore/localization/klocalizedstring.cpp #1030571:1030572
@@ -24,6 +24,7 @@
#include <kglobal.h>
#include <kdebug.h>
#include <klocale.h>
+#include <klocale_p.h>
#include <kcomponentdata.h>
#include <klibrary.h>
#include <kstandarddirs.h>
@@ -126,8 +127,6 @@
QHash<QString, KuitSemantics*> formatters;
- QMutex mutex;
-
KLocalizedStringPrivateStatics () :
theFence("|/|"),
startInterp("$["),
@@ -144,9 +143,7 @@
translits(),
- formatters(),
-
- mutex(QMutex::Recursive)
+ formatters()
{}
~KLocalizedStringPrivateStatics ()
@@ -216,7 +213,7 @@
QString KLocalizedStringPrivate::toString (const KLocale *locale) const
{
KLocalizedStringPrivateStatics *s = staticsKLSP;
- QMutexLocker lock(&s->mutex);
+ QMutexLocker lock(kLocaleMutex());
// Assure the message has been supplied.
if (msg.isEmpty())
@@ -474,7 +471,7 @@
const QString &ctxt) const
{
KLocalizedStringPrivateStatics *s = staticsKLSP;
- QMutexLocker lock(&s->mutex);
+ QMutexLocker lock(kLocaleMutex());
QString final = text;
@@ -499,7 +496,7 @@
bool &fallback) const
{
KLocalizedStringPrivateStatics *s = staticsKLSP;
- QMutexLocker lock(&s->mutex);
+ QMutexLocker lock(kLocaleMutex());
if (s->ktrs == NULL)
// Scripting engine not available.
@@ -564,7 +561,7 @@
// fallback is set to true if Transcript evaluation requested so.
KLocalizedStringPrivateStatics *s = staticsKLSP;
- QMutexLocker lock(&s->mutex);
+ QMutexLocker lock(kLocaleMutex());
result.clear();
fallback = false;
@@ -716,7 +713,7 @@
QVariant KLocalizedStringPrivate::segmentToValue (const QString &seg) const
{
KLocalizedStringPrivateStatics *s = staticsKLSP;
- QMutexLocker lock(&s->mutex);
+ QMutexLocker lock(kLocaleMutex());
// Return invalid variant if segment is either not a proper
// value reference, or the reference is out of bounds.
@@ -751,7 +748,7 @@
const QString &final) const
{
KLocalizedStringPrivateStatics *s = staticsKLSP;
- QMutexLocker lock(&s->mutex);
+ QMutexLocker lock(kLocaleMutex());
if (s->ktrs == NULL)
// Scripting engine not available.
@@ -945,7 +942,7 @@
void KLocalizedStringPrivate::loadTranscript ()
{
KLocalizedStringPrivateStatics *s = staticsKLSP;
- QMutexLocker lock(&s->mutex);
+ QMutexLocker lock(kLocaleMutex());
s->loadTranscriptCalled = true;
s->ktrs = NULL; // null indicates that Transcript is not available
@@ -979,7 +976,8 @@
return;
}
KLocalizedStringPrivateStatics *s = staticsKLSP;
- QMutexLocker lock(&s->mutex);
+ // Very important: do not the mutex here.
+ //QMutexLocker lock(kLocaleMutex());
// Find script modules for all included language/catalogs that have them,
// and remember their paths.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic