From a97a51a3cab0d0550167f3dce924865ae6fdb506 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 28 Feb 2019 17:08:00 +0100 Subject: Fix leak in SVG font nodes Their lifetime is controlled by the document, but the logic was confused and lost the node. Change-Id: Ib074dcf209d53ade894ee571a0bc08a1a7acfcab Reviewed-by: Edward Welbourne --- src/svg/qsvghandler.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index d30cf9f..fe79977 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -2615,17 +2615,17 @@ static QSvgStyleProperty *createFontNode(QSvgNode *parent, parent = parent->parent(); } - if (parent) { + if (parent && !myId.isEmpty()) { QSvgTinyDocument *doc = static_cast(parent); - QSvgFont *font = new QSvgFont(horizAdvX); - font->setFamilyName(myId); - if (!font->familyName().isEmpty()) { - if (!doc->svgFont(font->familyName())) - doc->addSvgFont(font); + QSvgFont *font = doc->svgFont(myId); + if (!font) { + font = new QSvgFont(horizAdvX); + font->setFamilyName(myId); + doc->addSvgFont(font); } return new QSvgFontStyle(font, doc); } - return 0; + return nullptr; } static bool parseFontFaceNode(QSvgStyleProperty *parent, -- cgit v1.2.1