aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Tapsell <john.tapsell.ext@basyskom.de>2010-08-17 02:19:56 +0900
committerTomas Junnonen <tomas.junnonen@nokia.com>2010-08-17 13:05:14 +0300
commit91aaf4b1c653ec4f66b609eb5b189883120b7336 (patch)
treedfd5638260a0b8588c02ef25c408697b9c321baa /src
parent26dcac95bf6c65ee770e06f1f2fb622ae192e7ab (diff)
Fixes: NB#180677 - Delete MLocale etc when MApplication is deleted
RevBy: Ville Voutilainen
Diffstat (limited to 'src')
-rw-r--r--src/corelib/core/mgconfitem.cpp19
-rw-r--r--src/corelib/i18n/mlocale.cpp5
-rw-r--r--src/corelib/i18n/mlocale.h2
3 files changed, 18 insertions, 8 deletions
diff --git a/src/corelib/core/mgconfitem.cpp b/src/corelib/core/mgconfitem.cpp
index 0adf4e4f..c541e7b7 100644
--- a/src/corelib/core/mgconfitem.cpp
+++ b/src/corelib/core/mgconfitem.cpp
@@ -49,19 +49,22 @@ struct MGConfItemPrivate {
static GConfClient *
get_gconf_client ()
{
- static bool initialized = false;
- static GConfClient *client;
+ static GConfClient *s_gconf_client = 0;
+ struct GConfClientDestroyer {
+ ~GConfClientDestroyer() { g_object_unref(s_gconf_client); s_gconf_client = 0; }
+ };
- if (initialized)
- return client;
+ static GConfClientDestroyer gconfClientDestroyer;
+ if (s_gconf_client)
+ return s_gconf_client;
- g_type_init ();
- client = gconf_client_get_default();
- initialized = true;
+ g_type_init();
+ s_gconf_client = gconf_client_get_default();
- return client;
+ return s_gconf_client;
}
+
#define withClient(c) for (GConfClient *c = get_gconf_client (); c; c = NULL)
static QByteArray convertKey(const QString &key)
diff --git a/src/corelib/i18n/mlocale.cpp b/src/corelib/i18n/mlocale.cpp
index 917b7064..5d687bf0 100644
--- a/src/corelib/i18n/mlocale.cpp
+++ b/src/corelib/i18n/mlocale.cpp
@@ -1117,6 +1117,11 @@ static QMutex defaultLocaleMutex;
// The static default locale
MLocale *MLocale::s_systemDefault = 0;
+struct MStaticLocaleDestroyer {
+ ~MStaticLocaleDestroyer() { delete MLocale::s_systemDefault; MLocale::s_systemDefault = 0; }
+};
+static MStaticLocaleDestroyer staticLocaleDestroyer;
+
void MLocale::setDefault(const MLocale &locale)
{
defaultLocaleMutex.lock();
diff --git a/src/corelib/i18n/mlocale.h b/src/corelib/i18n/mlocale.h
index 48439607..f048ef16 100644
--- a/src/corelib/i18n/mlocale.h
+++ b/src/corelib/i18n/mlocale.h
@@ -35,6 +35,7 @@ class MCalendar;
class MBreakIteratorPrivate;
class MLocalePrivate;
+class MStaticLocaleDestroyer;
/*!
* \class MLocale
@@ -1332,6 +1333,7 @@ private:
friend class MCalendar;
friend class MCollator;
+ friend class MStaticLocaleDestroyer;
friend class MIcuBreakIteratorPrivate;
private Q_SLOTS: