diff options
author | Mike FABIAN <mike.fabian@basyskom.de> | 2011-01-21 18:12:40 +0100 |
---|---|---|
committer | Mike FABIAN <mike.fabian@basyskom.de> | 2011-01-24 14:17:11 +0100 |
commit | 16698550cc46af274d969a7e0f7b353f3c816a6b (patch) | |
tree | 6dae58bb2c855f454daec8228c7264759a07cd44 | |
parent | ccd810e2f7fb32c2bd163e19fd4d6bb0b980c563 (diff) |
Changes: add method to check whether translation catalogs are already installed
RevBy: Holger Schröder
Details:
Needed to avoid endless loops like in bug#201837.
It is also necessary to move the
defaultLocaleMutex.unlock();
in MLocale::setDefault() *before* the
insertDirectionTrToQCoreApp();
because there is a deadlock otherwise.
-rw-r--r-- | src/corelib/i18n/mlocale.cpp | 17 | ||||
-rw-r--r-- | src/corelib/i18n/mlocale.h | 17 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/corelib/i18n/mlocale.cpp b/src/corelib/i18n/mlocale.cpp index 63018ddf..7d112432 100644 --- a/src/corelib/i18n/mlocale.cpp +++ b/src/corelib/i18n/mlocale.cpp @@ -1528,6 +1528,7 @@ void MLocale::setDefault(const MLocale &locale) (s_systemDefault->d_ptr)->removeTrFromQCoreApp(); *s_systemDefault = locale; } + defaultLocaleMutex.unlock(); // load special translations to make QApplication detect the // correct direction (see qapplication.cpp in the Qt source // code). If this is not done, the QEvent::LanguageChange events @@ -1539,7 +1540,6 @@ void MLocale::setDefault(const MLocale &locale) // triggered by // qApp->setLayoutDirection(s_systemDefault->textDirection()); (s_systemDefault->d_ptr)->insertDirectionTrToQCoreApp(); - defaultLocaleMutex.unlock(); // sends QEvent::LanguageChange to qApp: (s_systemDefault->d_ptr)->insertTrToQCoreApp(); @@ -2994,6 +2994,21 @@ void MLocale::removeTrCatalog(const QString &name) } } +bool MLocale::isInstalledTrCatalog(const QString &name) const +{ + Q_D(const MLocale); + if(name.isEmpty()) + return false; + MLocalePrivate::CatalogList::const_iterator it = d->_trTranslations.constBegin(); + while (it != d->_trTranslations.constEnd()) { + if ((*it)->_name == name) + return true; + else + ++it; + } + return false; +} + ///////////////////////////// //// translation methods //// diff --git a/src/corelib/i18n/mlocale.h b/src/corelib/i18n/mlocale.h index f196c1f4..aa4ab3f6 100644 --- a/src/corelib/i18n/mlocale.h +++ b/src/corelib/i18n/mlocale.h @@ -1491,6 +1491,8 @@ public: * QString translatedString = qtTrId("hello_msg"); * \endcode * + * \sa isInstalledTrCatalog(const QString &name) + * \sa removeTrCatalog(const QString &name) * \sa setDefault(const MLocale &locale) * \sa translationPaths() * \sa setTranslationPaths(const QStringList &paths) @@ -1505,10 +1507,25 @@ public: * * Removes the catalog from the list of translation catalogs used by this * MLocale. + * + * \sa isInstalledTrCatalog(const QString &name) + * \sa installTrCatalog(const QString &name) */ void removeTrCatalog(const QString &name); /*! + * \brief checks whether a translation catalog is installed nor not + * \param name of the translation catalog to check + * + * returns true if such a translation catalog has been installed + * already, false if not. + * + * \sa installTrCatalog(const QString &name) + * \sa removeTrCatalog(const QString &name) + */ + bool isInstalledTrCatalog(const QString &name) const; + + /*! * \brief tr() compatibility translation method. * \param context context of the translation * \param sourceText text to translate |