summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-05-19 09:48:41 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-05-23 14:14:17 +0000
commita15c16f5c806c9a564b0af660ccb010940091d4b (patch)
tree2bdd91d9c827c24bc9e453df6964c9128585b718 /src
parentb857b0ebe7333654d892c7660974307089fd3f5a (diff)
Fix memory leak when using small caps font
The small caps version of a font is kept as a QFontPrivate* which is manually reference counted, but we neglected to actually delete it when the reference count went to 0. [ChangeLog][Fonts] Fixed a memory leak when initializing a small caps font. Fixes: QTBUG-93068 Change-Id: Icc7fb7a59bf523da84d2e6fa026940a7d1230525 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Robert Löhning <robert.loehning@qt.io> (cherry picked from commit 11a40defff51dae2476e0da9f2b995a3a0f3bda8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qfont.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index e822854292..9ab0fa3141 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -220,8 +220,10 @@ QFontPrivate::~QFontPrivate()
if (engineData && !engineData->ref.deref())
delete engineData;
engineData = nullptr;
- if (scFont && scFont != this)
- scFont->ref.deref();
+ if (scFont && scFont != this) {
+ if (!scFont->ref.deref())
+ delete scFont;
+ }
scFont = nullptr;
}
@@ -630,8 +632,10 @@ void QFont::detach()
if (d->engineData && !d->engineData->ref.deref())
delete d->engineData;
d->engineData = nullptr;
- if (d->scFont && d->scFont != d.data())
- d->scFont->ref.deref();
+ if (d->scFont && d->scFont != d.data()) {
+ if (!d->scFont->ref.deref())
+ delete d->scFont;
+ }
d->scFont = nullptr;
return;
}