summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-10-29 11:52:43 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-31 11:50:23 +0100
commitab219c9594234356332351dd8b630d6963880b0f (patch)
treec4275a23bd70aeed6d061954f3a25806e9e63dd8 /src/gui/text
parent088fe949570ce31aba6d9b97a4084195cbb3b9e1 (diff)
Keep web fontdata alive as long as CG uses it
With OS X 10.9 font decoding appears to happen lazily, this means we have to ensure the data we provide CG is kept alive until CG dereferences it itself. Backport of 89ab2671051671ecf440ba480caf0b6b6768b1a9 Change-Id: I29d5bf9d6efac4668ea2c85fa5393ed1c1e621b5 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qrawfont_mac.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gui/text/qrawfont_mac.cpp b/src/gui/text/qrawfont_mac.cpp
index 7c14524a9f..b5e0b696d4 100644
--- a/src/gui/text/qrawfont_mac.cpp
+++ b/src/gui/text/qrawfont_mac.cpp
@@ -52,6 +52,13 @@ void QRawFontPrivate::platformCleanUp()
{
}
+static void releaseFontData(void* info, const void* data, size_t size)
+{
+ Q_UNUSED(data);
+ Q_UNUSED(size);
+ delete (QByteArray*)info;
+}
+
extern int qt_defaultDpi();
void QRawFontPrivate::platformLoadFromData(const QByteArray &fontData,
@@ -61,8 +68,9 @@ void QRawFontPrivate::platformLoadFromData(const QByteArray &fontData,
// Mac OS X ignores it
Q_UNUSED(hintingPreference);
- QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(NULL,
- fontData.constData(), fontData.size(), NULL);
+ QByteArray* fontDataCopy = new QByteArray(fontData);
+ QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(fontDataCopy,
+ fontDataCopy->constData(), fontDataCopy->size(), releaseFontData);
CGFontRef cgFont = CGFontCreateWithDataProvider(dataProvider);