]> git.saurik.com Git - wxWidgets.git/commitdiff
Loosen the assert in IsScrollIncrement().
authorVáclav Slavík <vslavik@fastmail.fm>
Fri, 30 Aug 2013 13:14:50 +0000 (13:14 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Fri, 30 Aug 2013 13:14:50 +0000 (13:14 +0000)
wxWindowGTK::GTKGetScrollEventType() tries to map GtkAdjustment's delta
to either step or page increment by comparing it with the respective
GtkAdjustment steps. Both of them can be 0, but this code is not
expected to be called in such case.

Yet, in practice, it occasionally is, see e.g.
http://devel.aegisub.org/ticket/979GTKGetScrollEventType (wxWebView is
prone to it as well).

Check for >= 0 instead, to be more robust when faced with unexpected
input from GTK+.

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

src/gtk/window.cpp

index 0be16df1c992ab92693d9ebd042631ed9ef39e08..3f5d2adf95479acb328b15bc5b0a105fface4f9e 100644 (file)
@@ -4601,7 +4601,9 @@ int wxWindowGTK::GetScrollRange( int orient ) const
 //   difference due to possible inexactness in floating point arithmetic
 static inline bool IsScrollIncrement(double increment, double x)
 {
 //   difference due to possible inexactness in floating point arithmetic
 static inline bool IsScrollIncrement(double increment, double x)
 {
-    wxASSERT(increment > 0);
+    wxASSERT(increment >= 0);
+    if ( increment == 0. )
+        return false;
     const double tolerance = 1.0 / 1024;
     return fabs(increment - fabs(x)) < tolerance;
 }
     const double tolerance = 1.0 / 1024;
     return fabs(increment - fabs(x)) < tolerance;
 }