From 26379d0320637b11519a2f161fb458eb9360ed88 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 20 Jan 2016 09:36:35 +0100 Subject: 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 --- .../themes/genericunix/qgenericunixthemes.cpp | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/platformsupport/themes/genericunix/qgenericunixthemes.cpp') 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; } -- cgit v1.2.3