summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-28 17:08:00 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-04-24 11:08:18 +0000
commita97a51a3cab0d0550167f3dce924865ae6fdb506 (patch)
tree2ebd4d38e10c636c3ff7160a5b6b0faf1bf64416
parent99218c5fc00d6124fdcef1a3e1954e658d10db28 (diff)
downloadqtsvg-a97a51a3cab0d0550167f3dce924865ae6fdb506.tar.gz
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 <edward.welbourne@qt.io>
-rw-r--r--src/svg/qsvghandler.cpp14
1 files 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<QSvgTinyDocument*>(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,