summaryrefslogtreecommitdiff
path: root/basegfx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-09-20 18:28:36 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-09-20 21:20:08 +0200
commite4a72aa946b6c41a91dc6e74634093a83b9c22bd (patch)
tree80ff1365c2411474f8c075c1ac8f45cfeb6326de /basegfx
parent11ec622b8405dcaabc359e3d6e38c8a9142dad6b (diff)
tdf#151056: avoid modifying the static shared DEFAULT instance
This was a thinko in commit e39fa3c4f5ae2560a4b6f6f789a0c5098ac43cf4 Simplify b2d(poly)polygon implementation This led to exponential growth of elements in each next polypolygon created from scratch, that immediately manifested with the complex SVG logo shown on the backing window. And finally, there's no const_cast/as_const left in the file :) Change-Id: Ie60f75ec86a8fa21799f4f1b589c04c9e4646183 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140248 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/source/polygon/b2dpolypolygon.cxx16
1 files changed, 10 insertions, 6 deletions
diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx
index 6ce3b398a1fb..1889ddae4220 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -299,13 +299,17 @@ public:
B2DPolyPolygon B2DPolyPolygon::getDefaultAdaptiveSubdivision() const
{
B2DPolyPolygon aRetval;
- // Avoid CoW overhead for the local variable
- auto dest = const_cast<ImplB2DPolyPolygon*>(std::as_const(aRetval).mpPolyPolygon.get());
- dest->reserve(count());
-
- for(sal_uInt32 a(0); a < count(); a++)
+ if (count())
{
- dest->append(getB2DPolygon(a).getDefaultAdaptiveSubdivision(), 1);
+ // Avoid CoW overhead for the local variable
+ // But detach from shared static DEFAULT
+ ImplB2DPolyPolygon& dest = aRetval.mpPolyPolygon.make_unique();
+ dest.reserve(count());
+
+ for (sal_uInt32 a(0); a < count(); a++)
+ {
+ dest.append(getB2DPolygon(a).getDefaultAdaptiveSubdivision(), 1);
+ }
}
return aRetval;