diff options
author | Thiago Macieira <thiago@kde.org> | 2011-07-20 16:06:58 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-21 08:54:00 +0200 |
commit | 6d3c0643020aaf002b985a16a66f3c289daea4f0 (patch) | |
tree | 875c76adf08242cd8ed4dd7678509b3d085dc51e /src/gui/text/qfontengine.cpp | |
parent | de587d736a1fd661c3fddeebefce02e436a2c7a5 (diff) |
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 <olivier.goffart@nokia.com>
Reviewed-on: http://codereview.qt.nokia.com/1895
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Diffstat (limited to 'src/gui/text/qfontengine.cpp')
-rw-r--r-- | src/gui/text/qfontengine.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index dec09821d3..a258b72708 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1110,12 +1110,19 @@ QByteArray QFontEngine::convertToPostscriptFontFamilyName(const QByteArray &fami return f; } -Q_GLOBAL_STATIC_WITH_INITIALIZER(QVector<QRgb>, qt_grayPalette, { - x->resize(256); - QRgb *it = x->data(); - for (int i = 0; i < x->size(); ++i, ++it) - *it = 0xff000000 | i | (i<<8) | (i<<16); -}) +class QRgbGreyPalette: public QVector<QRgb> +{ +public: + QRgbGreyPalette() + { + resize(256); + QRgb *it = data(); + for (int i = 0; i < size(); ++i, ++it) + *it = 0xff000000 | i | (i<<8) | (i<<16); + } +}; + +Q_GLOBAL_STATIC(QVector<QRgb>, qt_grayPalette) const QVector<QRgb> &QFontEngine::grayPalette() { |