diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-05-19 09:48:41 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-05-20 21:38:25 +0200 |
commit | 11a40defff51dae2476e0da9f2b995a3a0f3bda8 (patch) | |
tree | 7746e7f28734af0c0226a7e757a47230acd6dd5a /src/gui/text | |
parent | ea3a4a50039443c8370e43cf46be5748177d6875 (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
Pick-to: 6.1 5.15
Change-Id: Icc7fb7a59bf523da84d2e6fa026940a7d1230525
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qfont.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 4b2e257231..0ddf543e9c 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -258,8 +258,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; } @@ -650,8 +652,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; } |