svx/source/sdr/primitive2d/sdrdecompositiontools.cxx |   28 +++++++++++++++++++
 1 file changed, 28 insertions(+)

New commits:
commit a564dcff859e817015a87825cea3ad29b2d370ba
Author:     Armin Le Grand (Allotropia) <armin.le.gr...@me.com>
AuthorDate: Thu Jun 23 11:47:03 2022 +0200
Commit:     Armin Le Grand <armin.le.gr...@me.com>
CommitDate: Thu Jun 23 17:45:12 2022 +0200

    tdf#149650 avoid potential recursion with SdrPage content hierarchy
    
    Change-Id: I27e064eeedfb45a2fe96892f1d31da94b9976c50
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136303
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <armin.le.gr...@me.com>

diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx 
b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
index f05c0c92f2d9..04b6a16163a4 100644
--- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
+++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
@@ -60,6 +60,7 @@
 #include <svx/sdr/contact/viewobjectcontact.hxx>
 #include <svx/sdr/contact/displayinfo.hxx>
 #include <basegfx/polygon/b2dpolygonclipper.hxx>
+#include <set>
 
 using namespace com::sun::star;
 
@@ -330,8 +331,35 @@ void SlideBackgroundFillPrimitive2D::get2DDecomposition(
         const_cast< SlideBackgroundFillPrimitive2D* >(this)->mpLastVC = 
pViewContact;
     }
 
+    // tdf#149650 allow remember/detect of potential recursion for content 
creation.
+    // use a std::set association - instead of a single bool or adress - due 
to the
+    // possibility of multiple SlideBackgroundFillPrimitive2D's being used at 
the same
+    // refresh. Also possible would be a local member (bool), but that just 
makes the
+    // class more complicated. Working wth the adress is not a problem here 
since below
+    // it reliably gets added/removed while being incarnated only.
+    static std::set<const SlideBackgroundFillPrimitive2D*> 
potentiallyActiveRecursion;
+
+    if(potentiallyActiveRecursion.end() != 
potentiallyActiveRecursion.find(this))
+    {
+        // The method getPrimitive2DSequenceSubHierarchy used in 
create2DDecomposition
+        // above has the potential to create a recursion, e.g. when the 
content of a page
+        // contains a SdrPageObj that again displays the page content (and 
potentially so
+        // on).
+        // This is valid, but works like a fractal, showing page content
+        // smaller and smaller inside a page. This needs to be controlled here 
to avoid
+        // the recursion. In this case just allow one single step since
+        // we are mainly interested in the page's BG fill anyways
+        return;
+    }
+
+    // remember that we enter a potential recursion
+    potentiallyActiveRecursion.insert(this);
+
     // use parent implementation
     BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, 
rViewInformation);
+
+    // forget about potential recursion
+    potentiallyActiveRecursion.extract(this);
 }
 
 bool SlideBackgroundFillPrimitive2D::operator==(const BasePrimitive2D& 
rPrimitive) const

Reply via email to