From 00f50c953c8e989175c8643d40ccece81401b2a7 Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Sun, 22 Oct 2017 15:46:35 -0400 Subject: [PATCH] Fix saving and loading of polygons' fill rule This fixes a bug introduced in commit 8365f2f and improves the previous, suboptimal behaviour. Now, polygon fill rules should be saved and loaded correctly; and the changes should be reverse compatible (so that files created with an older version will be loaded correctly as well). --- src/adaptors/UBSvgSubsetAdaptor.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index 2cc7c8e5..9ebde9fe 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -1752,25 +1752,15 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol polygonItem->setColorOnLightBackground(color); } - /* - - Unfortunately the fill rule was never saved correctly until OpenBoard v1.4, - before then, it was always saved as even-odd. So we can't load it safely here. - Saving is now fixed, but any old documents would be loaded incorrectly if the code - below is used. It should be activated at some point in the future though. + // Before OpenBoard v1.4, fill rule was only saved if it was "Even-odd". Therefore if no fill rule + // is specified, we assume that it should be Winding fill. QStringRef fillRule = mXmlReader.attributes().value("fill-rule"); - if (!fillRule.isNull()) { - QString value = fillRule.toString(); - - if (value == "evenodd") - polygonItem->setFillRule(Qt::OddEvenFill); - else - polygonItem->setFillRule(Qt::WindingFill); - } - */ - polygonItem->setFillRule(Qt::WindingFill); + if (!fillRule.isNull() && fillRule.toString() == "evenodd") + polygonItem->setFillRule(Qt::OddEvenFill); + else + polygonItem->setFillRule(Qt::WindingFill); return polygonItem;