From: Vadim Zeitlin Date: Mon, 23 Jan 2012 11:28:12 +0000 (+0000) Subject: Fix incorrect scroll positions used in SetScrollbars(). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/7fa7e46b265964e2d22ce97e300d5d45cd851da1 Fix incorrect scroll positions used in SetScrollbars(). 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 --- diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index 7c84a72e18..81dedd9875 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -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) );