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

Norbert Thiebaud nthiebaud at gmail.com
Thu Feb 13 05:17:24 CET 2014


 vcl/source/window/window2.cxx |   78 +++++++++++++++++++++++++++++-------------
 1 file changed, 54 insertions(+), 24 deletions(-)

New commits:
commit 67b1dad8815f697e92258b8c079720f3a7028ea9
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Wed Feb 12 17:44:31 2014 -0600

    coverity#1130358 Deference after null check
    
    Change-Id: I3ce41c86f57ed65fd87d403e50df47e3343a5a41

diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index edd48db..2a047ff 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -1161,40 +1161,70 @@ sal_Bool Window::HandleScrollCommand( const CommandEvent& rCmd,
 
                         double deltaXInPixels = double(deltaPoint.X());
                         double deltaYInPixels = double(deltaPoint.Y());
-
-                        double visSizeX = double(pHScrl->GetVisibleSize());
-                        double visSizeY = double(pVScrl->GetVisibleSize());
-
                         Size winSize = this->GetOutputSizePixel();
 
-                        double ratioX = deltaXInPixels / double(winSize.getWidth());
-                        double ratioY = deltaYInPixels / double(winSize.getHeight());
-
-                        long deltaXInLogic = long(visSizeX * ratioX);
-                        long deltaYInLogic = long(visSizeY * ratioY);
-
-                        // Touch need to work by pixels. Did not apply this to
-                        // Android, as android code may require adaptations
-                        // to work with this scrolling code
+                        if(pHScrl)
+                        {
+                            double visSizeX = double(pHScrl->GetVisibleSize());
+                            double ratioX = deltaXInPixels / double(winSize.getWidth());
+                            long deltaXInLogic = long(visSizeX * ratioX);
+                            // Touch need to work by pixels. Did not apply this to
+                            // Android, as android code may require adaptations
+                            // to work with this scrolling code
 #ifndef IOS
-                        long lineSizeX = pHScrl->GetLineSize();
-                        long lineSizeY = pVScrl->GetLineSize();
+                            long lineSizeX = pHScrl->GetLineSize();
 
-                        deltaXInLogic /= lineSizeX;
-                        deltaYInLogic /= lineSizeY;
+                            if(lineSizeX)
+                            {
+                                deltaXInLogic /= lineSizeX;
+                            }
+                            else
+                            {
+                                deltaXInLogic = 0;
+                            }
 #endif
-
-                        if ( deltaXInLogic || deltaYInLogic )
+                            if ( deltaXInLogic)
+                            {
+#ifndef IOS
+                                bool isMultiplyByLineSize = true;
+#else
+                                bool isMultiplyByLineSize = false;
+#endif
+                                lcl_HandleScrollHelper( pHScrl, deltaXInLogic, isMultiplyByLineSize );
+                                bRet = sal_True;
+                            }
+                        }
+                        if(pVScrl)
                         {
+                            double visSizeY = double(pVScrl->GetVisibleSize());
+                            double ratioY = deltaYInPixels / double(winSize.getHeight());
+                            long deltaYInLogic = long(visSizeY * ratioY);
+
+                            // Touch need to work by pixels. Did not apply this to
+                            // Android, as android code may require adaptations
+                            // to work with this scrolling code
 #ifndef IOS
-                            bool isMultiplyByLineSize = true;
+                            long lineSizeY = pVScrl->GetLineSize();
+                            if(lineSizeY)
+                            {
+                                deltaYInLogic /= lineSizeY;
+                            }
+                            else
+                            {
+                                deltaYInLogic = 0;
+                            }
+#endif
+                            if ( deltaYInLogic )
+                            {
+#ifndef IOS
+                                bool isMultiplyByLineSize = true;
 #else
-                            bool isMultiplyByLineSize = false;
+                                bool isMultiplyByLineSize = false;
 #endif
-                            lcl_HandleScrollHelper( pHScrl, deltaXInLogic, isMultiplyByLineSize );
-                            lcl_HandleScrollHelper( pVScrl, deltaYInLogic, isMultiplyByLineSize );
+                                lcl_HandleScrollHelper( pVScrl, deltaYInLogic, isMultiplyByLineSize );
 
-                            bRet = sal_True;
+                                bRet = sal_True;
+                            }
                         }
                     }
                 }


More information about the Libreoffice-commits mailing list