From 6d3c0643020aaf002b985a16a66f3c289daea4f0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 20 Jul 2011 16:06:58 +0200 Subject: Get rid of the evilness of Q_GLOBAL_STATIC_WITH_INITIALIZER That macro is a nightmare. It leads to writing code that is thread-unsafe or other problems. So rewrite the code that used this macro to use special-purpose classes with constructors. This commit does not introduce new errors. The FIXME in qicon.cpp (qtIconCache()) was a condition already present. It does fix the race conditions that were present in qbrush.cpp nullBrushInstance() and qfontengine.cpp qt_grayPalette(). Specialising QGlobalStatic is also evil. Change-Id: I039311f6a5ac9ea4ad7b310b870a2adf888da7e5 Merge-request: 10 Reviewed-by: Olivier Goffart Reviewed-on: http://codereview.qt.nokia.com/1895 Reviewed-by: Qt Sanity Bot --- src/gui/image/qicon.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/gui/image/qicon.cpp') diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 7cf749fabc..724205f2fc 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -107,8 +107,18 @@ QT_BEGIN_NAMESPACE static QBasicAtomicInt serialNumCounter = Q_BASIC_ATOMIC_INITIALIZER(1); static void qt_cleanup_icon_cache(); -typedef QCache IconCache; -Q_GLOBAL_STATIC_WITH_INITIALIZER(IconCache, qtIconCache, qAddPostRoutine(qt_cleanup_icon_cache)) +namespace { + class IconCache: public QCache + { + public: + IconCache() + { + // ### FIXME: needs to be re-added if qApp is re-created + qAddPostRoutine(qt_cleanup_icon_cache); + } + }; +} +Q_GLOBAL_STATIC(IconCache, qtIconCache) static void qt_cleanup_icon_cache() { -- cgit v1.2.3