Remove Q_GLOBAL_STATIC_WITH_INITIALIZER from QtWidgets

Change-Id: Iecad85fbbfabe41c3a332be2ee0ce3a643db7731
Reviewed-on: http://codereview.qt-project.org/5025
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
This commit is contained in:
Lars Knoll 2011-09-15 22:28:07 +02:00 committed by Qt by Nokia
parent 0bc19b4997
commit ceb3a071d2
3 changed files with 22 additions and 4 deletions

View File

@ -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<QByteArray, QFont>::operator=(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFonts());
}
Q_GLOBAL_STATIC(FontHash, app_fonts)
FontHash *qt_app_fonts_hash()
{
return app_fonts();

View File

@ -287,7 +287,10 @@ public:
{ --threadData->loopLevel; }
};
typedef QHash<QByteArray, QFont> FontHash;
struct FontHash : public QHash<QByteArray, QFont>
{
FontHash();
};
FontHash *qt_app_fonts_hash();
typedef QHash<QByteArray, QPalette> PaletteHash;

View File

@ -107,8 +107,18 @@ 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))
namespace {
struct IconCache : public QCache<QString, QIcon>
{
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()
{