1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-18 19:52:09 +01:00

Fixed "float font sizes causing crash on style load" issue

This commit is contained in:
Martin Tůma 2021-07-13 17:31:37 +02:00
parent 199806a107
commit c5e1872c2e

View File

@ -156,6 +156,7 @@ void Style::text(QXmlStreamReader &reader, const Rule &rule,
int fontSize = 9; int fontSize = 9;
bool bold = false, italic = false; bool bold = false, italic = false;
QString fontFamily("Helvetica"); QString fontFamily("Helvetica");
bool ok;
if (attr.hasAttribute("k")) if (attr.hasAttribute("k"))
ri._key = attr.value("k").toLatin1(); ri._key = attr.value("k").toLatin1();
@ -163,10 +164,21 @@ void Style::text(QXmlStreamReader &reader, const Rule &rule,
ri._fillColor = QColor(attr.value("fill").toString()); ri._fillColor = QColor(attr.value("fill").toString());
if (attr.hasAttribute("stroke")) if (attr.hasAttribute("stroke"))
ri._strokeColor = QColor(attr.value("stroke").toString()); ri._strokeColor = QColor(attr.value("stroke").toString());
if (attr.hasAttribute("stroke-width")) if (attr.hasAttribute("stroke-width")) {
ri._strokeWidth = attr.value("stroke-width").toFloat(); ri._strokeWidth = attr.value("stroke-width").toFloat(&ok);
if (attr.hasAttribute("font-size")) if (!ok || ri._strokeWidth < 0) {
fontSize = attr.value("font-size").toInt(); reader.raiseError(attr.value("stroke-width")
+ ": invalid stroke-width");
return;
}
}
if (attr.hasAttribute("font-size")) {
fontSize = attr.value("font-size").toFloat(&ok);
if (!ok || fontSize < 0) {
reader.raiseError(attr.value("font-size") + ": invalid font-size");
return;
}
}
if (attr.hasAttribute("font-style")) { if (attr.hasAttribute("font-style")) {
QString style(attr.value("font-style").toString()); QString style(attr.value("font-style").toString());
if (style == "bold") if (style == "bold")
@ -192,6 +204,7 @@ void Style::text(QXmlStreamReader &reader, const Rule &rule,
ri._font.setItalic(italic); ri._font.setItalic(italic);
if (fontSize)
for (int i = 0; i < lists.size(); i++) for (int i = 0; i < lists.size(); i++)
lists[i]->append(ri); lists[i]->append(ri);