]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix incorrect scroll positions used in SetScrollbars().
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 23 Jan 2012 11:28:12 +0000 (11:28 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 23 Jan 2012 11:28:12 +0000 (11:28 +0000)
SetScrollbars() passed its input positions expressed in scroll units to
CalcUnscrolledPosition() which takes positions in pixels. This was definitely
wrong so don't do this and perform the conversion from scroll units to pixels
in SetScrollbars() itself for clarity instead.

It's not clear what concrete bugs, if any, does this fix as the calculated
positions are almost never used anyhow but the old code was obviously
incorrect and the new version has a chance of not being wrong so it's already
an improvement.

Closes #9988.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70443 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/scrlwing.cpp

index 7c84a72e18616d048e0bc795c191cbc69aa26c87..81dedd9875bf5ff84381ffb0d5956fce104eab55 100644 (file)
@@ -385,16 +385,17 @@ void wxScrollHelperBase::SetScrollbars(int pixelsPerUnitX,
                                        int yPos,
                                        bool noRefresh)
 {
-    int xpos, ypos;
+    // Convert positions expressed in scroll units to positions in pixels.
+    int xPosInPixels = (xPos + m_xScrollPosition)*m_xScrollPixelsPerLine,
+        yPosInPixels = (yPos + m_yScrollPosition)*m_yScrollPixelsPerLine;
 
-    CalcUnscrolledPosition(xPos, yPos, &xpos, &ypos);
     bool do_refresh =
     (
       (noUnitsX != 0 && m_xScrollLines == 0) ||
-      (noUnitsX < m_xScrollLines && xpos > pixelsPerUnitX * noUnitsX) ||
+      (noUnitsX < m_xScrollLines && xPosInPixels > pixelsPerUnitX * noUnitsX) ||
 
       (noUnitsY != 0 && m_yScrollLines == 0) ||
-      (noUnitsY < m_yScrollLines && ypos > pixelsPerUnitY * noUnitsY) ||
+      (noUnitsY < m_yScrollLines && yPosInPixels > pixelsPerUnitY * noUnitsY) ||
       (xPos != m_xScrollPosition) ||
       (yPos != m_yScrollPosition)
     );