]> git.saurik.com Git - wxWidgets.git/commitdiff
AdjustScrollbars can go into an infinite loop, so bail out after a few
authorJulian Smart <julian@anthemion.co.uk>
Fri, 29 Apr 2005 09:14:27 +0000 (09:14 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 29 Apr 2005 09:14:27 +0000 (09:14 +0000)
iterations.

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

docs/changes.txt
src/generic/scrlwing.cpp

index 1cc442e0531a904ac119369283d15ff4c21d7b3f..5500ee0fd445110ddda98d7fd90698ad9823684c 100644 (file)
@@ -9,6 +9,10 @@ All:
 
 - Added wxLaunchDefaultBrowser.
 
+All (GUI):
+
+- Fixed potential infinite loop when adjusting wxScrolledWindow scrollbars.
+
 wxMSW:
 
 - Fixed erroneous selection of content in wxComboBox when within a wxStaticBox
index 94a3d59f5f4d29dc5de63f66c0883742f3ec0e43..7c21cb2f1d09e84191a53adb4216ab7935b85eb7 100644 (file)
@@ -649,8 +649,13 @@ void wxScrollHelper::AdjustScrollbars()
     //     it here for now but it would be better to ensure that all ports
     //     generate EVT_SIZE when scrollbars [dis]appear, emulating it if
     //     necessary, and remove it later
+    // JACS: Stop potential infinite loop by limiting number of iterations
+    int iterationCount = 0;
+    const int iterationMax = 5;
     do
     {
+        iterationCount ++;
+        
         GetTargetSize(&w, 0);
 
         // scroll lines per page: if 0, no scrolling is needed
@@ -762,7 +767,7 @@ void wxScrollHelper::AdjustScrollbars()
         oldh = h;
 
         GetTargetSize( &w, &h );
-    } while ( w != oldw || h != oldh );
+    } while ( (w != oldw || h != oldh) && (iterationCount < iterationMax) );
 
 #ifdef __WXMOTIF__
     // Sorry, some Motif-specific code to implement a backing pixmap