From ceb3a071d2e5bf4f3c6ea30dec983c3852959ed9 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 15 Sep 2011 22:28:07 +0200 Subject: Remove Q_GLOBAL_STATIC_WITH_INITIALIZER from QtWidgets Change-Id: Iecad85fbbfabe41c3a332be2ee0ce3a643db7731 Reviewed-on: http://codereview.qt-project.org/5025 Reviewed-by: Qt Sanity Bot Reviewed-by: Bradley T. Hughes --- src/widgets/kernel/qapplication.cpp | 7 ++++++- src/widgets/kernel/qapplication_p.h | 5 ++++- src/widgets/kernel/qicon.cpp | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 15ad5ec13e..83a3468ed6 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -499,7 +499,12 @@ PaletteHash *qt_app_palettes_hash() return app_palettes(); } -Q_GLOBAL_STATIC_WITH_INITIALIZER(FontHash, app_fonts, { *x = QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFonts(); } ) +FontHash::FontHash() +{ + QHash::operator=(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFonts()); +} + +Q_GLOBAL_STATIC(FontHash, app_fonts) FontHash *qt_app_fonts_hash() { return app_fonts(); diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 6efee02195..e466528cfb 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -287,7 +287,10 @@ public: { --threadData->loopLevel; } }; -typedef QHash FontHash; +struct FontHash : public QHash +{ + FontHash(); +}; FontHash *qt_app_fonts_hash(); typedef QHash PaletteHash; diff --git a/src/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp index bb9f56b715..73f8a2a360 100644 --- a/src/widgets/kernel/qicon.cpp +++ b/src/widgets/kernel/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 { + struct IconCache : public QCache + { + IconCache() + { + // ### note: won't readd if QApplication is re-created! + qAddPostRoutine(qt_cleanup_icon_cache); + } + }; +} + +Q_GLOBAL_STATIC(IconCache, qtIconCache) static void qt_cleanup_icon_cache() { -- cgit v1.2.3