[Libreoffice-commits] core.git: 3 commits - basegfx/source

Michael Stahl mstahl at redhat.com
Fri Aug 25 19:30:18 UTC 2017


 basegfx/source/matrix/b3dhommatrix.cxx    |   13 ++----------
 basegfx/source/polygon/b2dpolygon.cxx     |   31 ++++++++++++++++++++----------
 basegfx/source/polygon/b2dpolypolygon.cxx |    9 ++------
 3 files changed, 27 insertions(+), 26 deletions(-)

New commits:
commit 64ced968cc82b552e178da033e7a3b5af6996ae1
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Aug 25 20:56:28 2017 +0200

    basegfx: remove global ImplB2DPolyPolygon
    
    Change-Id: I6035aaf8aabf71062bb63a4d416c253378fb4756

diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx
index 9c6b1eb50fe9..eaed3bacdc54 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -21,7 +21,6 @@
 #include <osl/diagnose.h>
 #include <basegfx/polygon/b2dpolygon.hxx>
 #include <basegfx/polygon/b2dpolypolygontools.hxx>
-#include <rtl/instance.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
 
 #include <functional>
@@ -170,11 +169,9 @@ public:
 
 namespace basegfx
 {
-    namespace { struct DefaultPolyPolygon: public rtl::Static<B2DPolyPolygon::ImplType,
-                                                              DefaultPolyPolygon> {}; }
 
-    B2DPolyPolygon::B2DPolyPolygon() :
-        mpPolyPolygon(DefaultPolyPolygon::get())
+    B2DPolyPolygon::B2DPolyPolygon()
+        : mpPolyPolygon()
     {
     }
 
@@ -325,7 +322,7 @@ namespace basegfx
 
     void B2DPolyPolygon::clear()
     {
-        mpPolyPolygon = DefaultPolyPolygon::get();
+        *mpPolyPolygon = ImplB2DPolyPolygon();
     }
 
     bool B2DPolyPolygon::isClosed() const
commit 7e911e9cd469d30369c213aa529675b3f7c4f0e8
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Aug 25 20:51:22 2017 +0200

    basegfx: remove global ImplB2DPolygon
    
    Change-Id: Ibd97ba1d7cc4e04203142057c47a74034cc4f70f

diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx
index 00eaa89d1282..aa528ad861ac 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -23,7 +23,6 @@
 #include <basegfx/vector/b2dvector.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <basegfx/curve/b2dcubicbezier.hxx>
-#include <rtl/instance.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <algorithm>
 #include <memory>
@@ -632,7 +631,24 @@ public:
         }
     }
 
-    ImplB2DPolygon& operator=( const ImplB2DPolygon& ) = delete;
+    ImplB2DPolygon& operator=(const ImplB2DPolygon& rOther)
+    {
+        if (this != &rOther)
+        {
+            mpControlVector.reset();
+            mpBufferedData.reset();
+            maPoints = rOther.maPoints;
+            mbIsClosed = rOther.mbIsClosed;
+            if (rOther.mpControlVector && rOther.mpControlVector->isUsed())
+            {
+                mpControlVector.reset( new ControlVectorArray2D(*rOther.mpControlVector) );
+
+                if(!mpControlVector->isUsed())
+                    mpControlVector.reset();
+            }
+        }
+        return *this;
+    }
 
     sal_uInt32 count() const
     {
@@ -1091,17 +1107,12 @@ public:
 
 namespace basegfx
 {
-    namespace
-    {
-        struct DefaultPolygon: public rtl::Static<B2DPolygon::ImplType, DefaultPolygon> {};
-    }
-
     B2DPolygon::B2DPolygon()
-    :   mpPolygon(DefaultPolygon::get())
+        : mpPolygon()
     {}
 
     B2DPolygon::B2DPolygon(std::initializer_list<basegfx::B2DPoint> aPoints)
-        : mpPolygon(DefaultPolygon::get())
+        : mpPolygon()
     {
         for (const basegfx::B2DPoint& rPoint : aPoints)
         {
@@ -1432,7 +1443,7 @@ namespace basegfx
 
     void B2DPolygon::clear()
     {
-        mpPolygon = DefaultPolygon::get();
+        *mpPolygon = ImplB2DPolygon();
     }
 
     bool B2DPolygon::isClosed() const
commit 0157f98861d589caa60f1ef3dacebb0137d23afe
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Aug 25 20:27:34 2017 +0200

    basegfx: remove global 3D IdentityMatrix thread safety hazard
    
    On a tinderbox, CppunitTest_chart2_export crashed in
    basegfx::B3DHomMatrix::isEqual(), with other threads in other basegfx
    code.
    
    The UnsafeRefCountingPolicy on the global IdentityMatrix is likely the
    problem.
    
    Change-Id: Ib142c6f286453d61bd948fb0c184cd68fd313b0f

diff --git a/basegfx/source/matrix/b3dhommatrix.cxx b/basegfx/source/matrix/b3dhommatrix.cxx
index 1a88c8b5c777..e6a2bd3b4f88 100644
--- a/basegfx/source/matrix/b3dhommatrix.cxx
+++ b/basegfx/source/matrix/b3dhommatrix.cxx
@@ -17,7 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <rtl/instance.hxx>
 #include <basegfx/matrix/b3dhommatrix.hxx>
 #include <hommatrixtemplate.hxx>
 #include <basegfx/vector/b3dvector.hxx>
@@ -30,11 +29,8 @@ namespace basegfx
     {
     };
 
-    namespace { struct IdentityMatrix : public rtl::Static< B3DHomMatrix::ImplType,
-                                                            IdentityMatrix > {}; }
-
-    B3DHomMatrix::B3DHomMatrix() :
-        mpImpl( IdentityMatrix::get() ) // use common identity matrix
+    B3DHomMatrix::B3DHomMatrix()
+        : mpImpl() // identity
     {
     }
 
@@ -81,15 +77,12 @@ namespace basegfx
 
     bool B3DHomMatrix::isIdentity() const
     {
-        if(mpImpl.same_object(IdentityMatrix::get()))
-            return true;
-
         return mpImpl->isIdentity();
     }
 
     void B3DHomMatrix::identity()
     {
-        mpImpl = IdentityMatrix::get();
+        *mpImpl = Impl3DHomMatrix();
     }
 
     bool B3DHomMatrix::invert()


More information about the Libreoffice-commits mailing list