diff options
author | Trond Kjernåsen <trond@trolltech.com> | 2010-02-09 15:10:40 (GMT) |
---|---|---|
committer | Trond Kjernåsen <trond@trolltech.com> | 2010-02-09 15:13:56 (GMT) |
commit | dadfdfaa320aa5951d8512428d59e762b0da79f3 (patch) | |
tree | 6fed85b65b6038f3ff0178c20d8a5090bcca34d7 /src/gui/image | |
parent | 3b56735e8d90cb760bf56fc07fbd87e48ca08619 (diff) | |
download | Qt-dadfdfaa320aa5951d8512428d59e762b0da79f3.zip Qt-dadfdfaa320aa5951d8512428d59e762b0da79f3.tar.gz Qt-dadfdfaa320aa5951d8512428d59e762b0da79f3.tar.bz2 |
Fixed some global QIcon/QPixmap instances that leaked handles on X11.
Never ever create global cache objects that deletes QPixmaps when
destructed!
Task-number: QTBUG-8046
Reviewed-by: Friedemann Kleint
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qicon.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index ac1d303..bf6eb8d 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -104,6 +104,15 @@ QT_BEGIN_NAMESPACE static QBasicAtomicInt serialNumCounter = Q_BASIC_ATOMIC_INITIALIZER(1); +static void qt_cleanup_icon_cache(); +typedef QCache<QString, QIcon> IconCache; +Q_GLOBAL_STATIC_WITH_INITIALIZER(IconCache, qtIconCache, qAddPostRoutine(qt_cleanup_icon_cache)) + +static void qt_cleanup_icon_cache() +{ + qtIconCache()->clear(); +} + QIconPrivate::QIconPrivate() : engine(0), ref(1), serialNum(serialNumCounter.fetchAndAddRelaxed(1)), @@ -963,15 +972,13 @@ QString QIcon::themeName() */ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback) { - static QCache <QString, QIcon> iconCache; - QIcon icon; - if (iconCache.contains(name)) { - icon = *iconCache.object(name); + if (qtIconCache()->contains(name)) { + icon = *qtIconCache()->object(name); } else { QIcon *cachedIcon = new QIcon(new QIconLoaderEngine(name)); - iconCache.insert(name, cachedIcon); + qtIconCache()->insert(name, cachedIcon); icon = *cachedIcon; } |