diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-01-20 09:36:35 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-01-21 06:02:20 +0000 |
commit | 26379d0320637b11519a2f161fb458eb9360ed88 (patch) | |
tree | 518be14190332e67d1dba94797655d793eaf56af /src | |
parent | 1f9a06c2949cd206235e75d20d0183fee927cb3e (diff) |
QGnomeTheme: Change the QFont members to pointer members.
When initializing the font members in the QGnomeTheme constructor,
the QFont constructor called QGuiApplication::font() which in
turn calls initFontUnlocked(), initializing
QGuiApplicationPrivate::app_font to QPlatformFontDatabase::defaultFont()
("Deja Vu 12") since QGuiApplicationPrivate::platformTheme() is still
0 at that point.
Change the fonts to pointer members and initialize them
delayed in QGnomeThemePrivate::configureFonts() instead.
Task-number: QTBUG-49095
Change-Id: I3282ea8484e04827be2a424f5ea3e34d607c4bc5
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/platformsupport/themes/genericunix/qgenericunixthemes.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 8f6171f217..0bcd3464b7 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -577,23 +577,23 @@ const char *QGnomeTheme::name = "gnome"; class QGnomeThemePrivate : public QPlatformThemePrivate { public: - QGnomeThemePrivate() : fontsConfigured(false) { } + QGnomeThemePrivate() : systemFont(Q_NULLPTR), fixedFont(Q_NULLPTR) {} + ~QGnomeThemePrivate() { delete systemFont; delete fixedFont; } + void configureFonts(const QString >kFontName) const { - Q_ASSERT(!fontsConfigured); + Q_ASSERT(!systemFont); const int split = gtkFontName.lastIndexOf(QChar::Space); float size = gtkFontName.mid(split+1).toFloat(); QString fontName = gtkFontName.left(split); - systemFont = QFont(fontName, size); - fixedFont = QFont(QLatin1String("monospace"), systemFont.pointSize()); - fixedFont.setStyleHint(QFont::TypeWriter); - fontsConfigured = true; + systemFont = new QFont(fontName, size); + fixedFont = new QFont(QLatin1String("monospace"), systemFont->pointSize()); + fixedFont->setStyleHint(QFont::TypeWriter); } - mutable QFont systemFont; - mutable QFont fixedFont; - mutable bool fontsConfigured; + mutable QFont *systemFont; + mutable QFont *fixedFont; }; QGnomeTheme::QGnomeTheme() @@ -632,13 +632,13 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const const QFont *QGnomeTheme::font(Font type) const { Q_D(const QGnomeTheme); - if (!d->fontsConfigured) + if (!d->systemFont) d->configureFonts(gtkFontName()); switch (type) { case QPlatformTheme::SystemFont: - return &d->systemFont; + return d->systemFont; case QPlatformTheme::FixedFont: - return &d->fixedFont; + return d->fixedFont; default: return 0; } |