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>
This commit is contained in:
parent
1f9a06c294
commit
26379d0320
@ -577,23 +577,23 @@ const char *QGnomeTheme::name = "gnome";
|
|||||||
class QGnomeThemePrivate : public QPlatformThemePrivate
|
class QGnomeThemePrivate : public QPlatformThemePrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QGnomeThemePrivate() : fontsConfigured(false) { }
|
QGnomeThemePrivate() : systemFont(Q_NULLPTR), fixedFont(Q_NULLPTR) {}
|
||||||
|
~QGnomeThemePrivate() { delete systemFont; delete fixedFont; }
|
||||||
|
|
||||||
void configureFonts(const QString >kFontName) const
|
void configureFonts(const QString >kFontName) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(!fontsConfigured);
|
Q_ASSERT(!systemFont);
|
||||||
const int split = gtkFontName.lastIndexOf(QChar::Space);
|
const int split = gtkFontName.lastIndexOf(QChar::Space);
|
||||||
float size = gtkFontName.mid(split+1).toFloat();
|
float size = gtkFontName.mid(split+1).toFloat();
|
||||||
QString fontName = gtkFontName.left(split);
|
QString fontName = gtkFontName.left(split);
|
||||||
|
|
||||||
systemFont = QFont(fontName, size);
|
systemFont = new QFont(fontName, size);
|
||||||
fixedFont = QFont(QLatin1String("monospace"), systemFont.pointSize());
|
fixedFont = new QFont(QLatin1String("monospace"), systemFont->pointSize());
|
||||||
fixedFont.setStyleHint(QFont::TypeWriter);
|
fixedFont->setStyleHint(QFont::TypeWriter);
|
||||||
fontsConfigured = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutable QFont systemFont;
|
mutable QFont *systemFont;
|
||||||
mutable QFont fixedFont;
|
mutable QFont *fixedFont;
|
||||||
mutable bool fontsConfigured;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QGnomeTheme::QGnomeTheme()
|
QGnomeTheme::QGnomeTheme()
|
||||||
@ -632,13 +632,13 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
|
|||||||
const QFont *QGnomeTheme::font(Font type) const
|
const QFont *QGnomeTheme::font(Font type) const
|
||||||
{
|
{
|
||||||
Q_D(const QGnomeTheme);
|
Q_D(const QGnomeTheme);
|
||||||
if (!d->fontsConfigured)
|
if (!d->systemFont)
|
||||||
d->configureFonts(gtkFontName());
|
d->configureFonts(gtkFontName());
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QPlatformTheme::SystemFont:
|
case QPlatformTheme::SystemFont:
|
||||||
return &d->systemFont;
|
return d->systemFont;
|
||||||
case QPlatformTheme::FixedFont:
|
case QPlatformTheme::FixedFont:
|
||||||
return &d->fixedFont;
|
return d->fixedFont;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user