From 115cacce0c69ac2f3ff769cf93e72c562fda98b7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 13 Aug 2003 23:55:52 +0000 Subject: [PATCH] fixed extraneous scrolling when scrollbars are added/removed (patch 788026; bug 746618) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@22834 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/scrlwing.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index 91c02243d2..72b6e4eb3f 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -603,6 +603,20 @@ int wxScrollHelper::CalcScrollInc(wxScrollWinEvent& event) // Adjust the scrollbars - new version. void wxScrollHelper::AdjustScrollbars() { + static bool s_isInside = false; + if ( s_isInside ) + { + // don't reenter AdjustScrollbars() while another call to + // AdjustScrollbars() is in progress because this may lead to calling + // ScrollWindow() twice and this can really happen under MSW if + // SetScrollbar() call below adds or removes the scrollbar which + // changes the window size and hence results in another + // AdjustScrollbars() call + return; + } + + s_isInside = true; + #ifdef __WXMAC__ m_targetWindow->MacUpdateImmediately(); #endif @@ -678,7 +692,7 @@ void wxScrollHelper::AdjustScrollbars() oldh = h; GetTargetSize( &w, &h ); - } while ( w != oldw && h != oldh ); + } while ( w != oldw || h != oldh ); #ifdef __WXMOTIF__ // Sorry, some Motif-specific code to implement a backing pixmap @@ -734,6 +748,8 @@ void wxScrollHelper::AdjustScrollbars() #ifdef __WXMAC__ m_targetWindow->MacUpdateImmediately(); #endif + + s_isInside = false; } void wxScrollHelper::DoPrepareDC(wxDC& dc)