diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-04-26 15:51:44 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-04-26 22:09:14 +0200 |
commit | 719d81a6c163356c93ea5d57ff8680bf4266a563 (patch) | |
tree | 07192600f7102e5fa2f501563889e8291682b947 /drawinglayer/source/primitive2d/sceneprimitive2d.cxx | |
parent | 6d6ed164c444ae895dd5f4f1696bbcf927897a04 (diff) |
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@redhat.com>
Diffstat (limited to 'drawinglayer/source/primitive2d/sceneprimitive2d.cxx')
-rw-r--r-- | drawinglayer/source/primitive2d/sceneprimitive2d.cxx | 32 |
1 files changed, 19 insertions, 13 deletions
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); |