summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qsoftkeymanager.cpp
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2011-08-02 13:38:45 +0100
committermread <qt-info@nokia.com>2011-08-02 13:38:45 +0100
commit448fffdd8f22a1b5af07b20c8ff5cf3f0f8de608 (patch)
tree3324379f044b8ecbbd7075fcd28879fd6655c762 /src/gui/kernel/qsoftkeymanager.cpp
parente3a22e7e91c0231acfaecfd8c2c77131c2930d96 (diff)
Preventing QSoftkeyManager giving false positive memory leaks
QSoftkeyManager has a global static instance that was not being deleted on app exit. This global static instance can own other objects, the number of which grow with use up to a limit. This gives the appearance of a memory leak when the app exits and you see increasing heap cell counts. The change is to use a QScopedPointer to clean up the static on app exit. Reviewed-by: Miikka Heikkinen
Diffstat (limited to 'src/gui/kernel/qsoftkeymanager.cpp')
-rw-r--r--src/gui/kernel/qsoftkeymanager.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp
index a866da3245..500bcff9f1 100644
--- a/src/gui/kernel/qsoftkeymanager.cpp
+++ b/src/gui/kernel/qsoftkeymanager.cpp
@@ -54,7 +54,7 @@
#ifndef QT_NO_SOFTKEYMANAGER
QT_BEGIN_NAMESPACE
-QSoftKeyManager *QSoftKeyManagerPrivate::self = 0;
+QScopedPointer<QSoftKeyManager> QSoftKeyManagerPrivate::self(0);
QString QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey)
{
@@ -85,9 +85,9 @@ QString QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey)
QSoftKeyManager *QSoftKeyManager::instance()
{
if (!QSoftKeyManagerPrivate::self)
- QSoftKeyManagerPrivate::self = new QSoftKeyManager;
+ QSoftKeyManagerPrivate::self.reset(new QSoftKeyManager);
- return QSoftKeyManagerPrivate::self;
+ return QSoftKeyManagerPrivate::self.data();
}
QSoftKeyManager::QSoftKeyManager() :