[Libreoffice-commits] core.git: drawinglayer/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 26 20:10:39 UTC 2019


 drawinglayer/source/primitive2d/sceneprimitive2d.cxx |   32 +++++++++++--------
 1 file changed, 19 insertions(+), 13 deletions(-)

New commits:
commit 719d81a6c163356c93ea5d57ff8680bf4266a563
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Apr 26 15:51:44 2019 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Apr 26 22:09:14 2019 +0200

    Avoid division by zero
    
    These areas are zero when you start to draw a 3D object with the mouse.
    
    Change-Id: I003ec06b42351b5c4b2b59b9f908fb82ab6e9b35
    Reviewed-on: https://gerrit.libreoffice.org/71373
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
index ddd18102f347..b747e8e6a759 100644
--- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
@@ -263,20 +263,23 @@ namespace drawinglayer
                     // only needed for dragging), reduce resolution extra
                     // to speed up dragging interactions
                     const double fArea(fViewSizeX * fViewSizeY);
-                    double fReducedVisualisationFactor(1.0 / (sqrt(fArea) * (1.0 / 170.0)));
-
-                    if(fReducedVisualisationFactor > 1.0)
-                    {
-                        fReducedVisualisationFactor = 1.0;
-                    }
-                    else if(fReducedVisualisationFactor < 0.20)
+                    if (fArea != 0.0)
                     {
-                        fReducedVisualisationFactor = 0.20;
-                    }
+                        double fReducedVisualisationFactor(1.0 / (sqrt(fArea) * (1.0 / 170.0)));
 
-                    if(fReducedVisualisationFactor != 1.0)
-                    {
-                        fReduceFactor *= fReducedVisualisationFactor;
+                        if(fReducedVisualisationFactor > 1.0)
+                        {
+                            fReducedVisualisationFactor = 1.0;
+                        }
+                        else if(fReducedVisualisationFactor < 0.20)
+                        {
+                            fReducedVisualisationFactor = 0.20;
+                        }
+
+                        if(fReducedVisualisationFactor != 1.0)
+                        {
+                            fReduceFactor *= fReducedVisualisationFactor;
+                        }
                     }
                 }
 
@@ -292,7 +295,10 @@ namespace drawinglayer
 
                     // bring to unit coordinates by applying inverse DiscreteRange
                     aObjToUnit.translate(-aDiscreteRange.getMinX(), -aDiscreteRange.getMinY());
-                    aObjToUnit.scale(1.0 / aDiscreteRange.getWidth(), 1.0 / aDiscreteRange.getHeight());
+                    if (aDiscreteRange.getWidth() != 0.0 && aDiscreteRange.getHeight() != 0.0)
+                    {
+                        aObjToUnit.scale(1.0 / aDiscreteRange.getWidth(), 1.0 / aDiscreteRange.getHeight());
+                    }
 
                     // calculate transformed user coordinate system
                     const basegfx::B2DPoint aStandardNull(0.0, 0.0);


More information about the Libreoffice-commits mailing list