summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-03-15 16:09:59 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-03-23 20:14:18 +0100
commitee15aa74825d4486979e64aa988af1927572e708 (patch)
tree8f37962e8e597ece81d863953c0e7df33950f075 /src/plugins/platforms/ios
parent8c4894f94bd43f47d05d632b48b7ec51fc0bcbd6 (diff)
CoreText: Maintain theme fonts in the font database instead of themes
The ownership of the fonts were handled in the iOS and macOS themes, but the CoreText font database also kept a reference to these fonts. As there was no way for the themes to reset the font database references we could potentially end up in a situation where the font database had stale references. And as the font database would not rebuild the theme fonts once populated the themes then would not be able to build a new list of theme fonts. Moving the ownership to the font database makes semantics and management of the fonts clearer. Pick-to: 6.3 6.2 Change-Id: I61756abaf5487f28d520dfa1cf7a8ee2d716cce6 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r--src/plugins/platforms/ios/qiostheme.h2
-rw-r--r--src/plugins/platforms/ios/qiostheme.mm10
2 files changed, 3 insertions, 9 deletions
diff --git a/src/plugins/platforms/ios/qiostheme.h b/src/plugins/platforms/ios/qiostheme.h
index c9d833713d..594031599a 100644
--- a/src/plugins/platforms/ios/qiostheme.h
+++ b/src/plugins/platforms/ios/qiostheme.h
@@ -68,8 +68,6 @@ public:
static void initializeSystemPalette();
private:
- mutable QHash<QPlatformTheme::Font, QFont *> m_fonts;
-
static QPalette s_systemPalette;
};
diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm
index 584dd1c8fc..9131963818 100644
--- a/src/plugins/platforms/ios/qiostheme.mm
+++ b/src/plugins/platforms/ios/qiostheme.mm
@@ -70,7 +70,6 @@ QIOSTheme::QIOSTheme()
QIOSTheme::~QIOSTheme()
{
- qDeleteAll(m_fonts);
}
QPalette QIOSTheme::s_systemPalette;
@@ -170,12 +169,9 @@ QVariant QIOSTheme::themeHint(ThemeHint hint) const
const QFont *QIOSTheme::font(Font type) const
{
- if (m_fonts.isEmpty()) {
- QCoreTextFontDatabase *ctfd = static_cast<QCoreTextFontDatabase *>(QGuiApplicationPrivate::platformIntegration()->fontDatabase());
- m_fonts = ctfd->themeFonts();
- }
-
- return m_fonts.value(type, 0);
+ const auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();
+ const auto *coreTextFontDatabase = static_cast<QCoreTextFontDatabase *>(platformIntegration->fontDatabase());
+ return coreTextFontDatabase->themeFonts().value(type, nullptr);
}
QT_END_NAMESPACE