diff options
author | mread <qt-info@nokia.com> | 2011-08-02 12:38:45 (GMT) |
---|---|---|
committer | mread <qt-info@nokia.com> | 2011-08-02 12:38:45 (GMT) |
commit | 448fffdd8f22a1b5af07b20c8ff5cf3f0f8de608 (patch) | |
tree | 3324379f044b8ecbbd7075fcd28879fd6655c762 /src/gui/kernel/qsoftkeymanager.cpp | |
parent | e3a22e7e91c0231acfaecfd8c2c77131c2930d96 (diff) | |
download | Qt-448fffdd8f22a1b5af07b20c8ff5cf3f0f8de608.zip Qt-448fffdd8f22a1b5af07b20c8ff5cf3f0f8de608.tar.gz Qt-448fffdd8f22a1b5af07b20c8ff5cf3f0f8de608.tar.bz2 |
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.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index a866da3..500bcff 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() : |