]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/scrlwing.cpp
Corrected typo
[wxWidgets.git] / src / generic / scrlwing.cpp
index 46b409c65dc0b6c6beb3f029d8c5c53f5e8f4347..bce06f0b5eb58a5961db55f66d3173117c14172a 100644 (file)
@@ -44,6 +44,7 @@
 #include "wx/timer.h"
 #endif
 #include "wx/sizer.h"
+#include "wx/recguard.h"
 
 #ifdef __WXMSW__
     #include <windows.h> // for DLGC_WANTARROWS
@@ -621,6 +622,19 @@ int wxScrollHelper::CalcScrollInc(wxScrollWinEvent& event)
 // Adjust the scrollbars - new version.
 void wxScrollHelper::AdjustScrollbars()
 {
+    static wxRecursionGuardFlag s_flagReentrancy;
+    wxRecursionGuard guard(s_flagReentrancy);
+    if ( guard.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;
+    }
+
 #ifdef __WXMAC__
     m_targetWindow->Update();
 #endif
@@ -722,7 +736,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