From 81309f083d51e33bd24dc63e3698c6a39f31f4f7 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Wed, 11 Mar 2020 22:10:22 -0700 Subject: [PATCH] Ensure that scrollbar GtkRange page increment is set to a positive value It should not be less than the step increment, which is always one. See #18688 --- src/gtk/scrolbar.cpp | 5 ++++- src/gtk/scrolwin.cpp | 2 ++ src/gtk/window.cpp | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gtk/scrolbar.cpp b/src/gtk/scrolbar.cpp index 3838510e77..f9fc488838 100644 --- a/src/gtk/scrolbar.cpp +++ b/src/gtk/scrolbar.cpp @@ -201,12 +201,15 @@ void wxScrollBar::SetThumbPosition( int viewStart ) void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize, bool) { - if (range == 0) + if (range <= 0) { // GtkRange requires upper > lower range = + pageSize = thumbSize = 1; } + else if (pageSize <= 0) + pageSize = 1; g_signal_handlers_block_by_func(m_widget, (void*)gtk_value_changed, this); GtkRange* widget = GTK_RANGE(m_widget); GtkAdjustment* adj = gtk_range_get_adjustment(widget); diff --git a/src/gtk/scrolwin.cpp b/src/gtk/scrolwin.cpp index 95765bf0c7..54ed62a9c6 100644 --- a/src/gtk/scrolwin.cpp +++ b/src/gtk/scrolwin.cpp @@ -54,6 +54,8 @@ void wxScrollHelper::DoAdjustScrollbar(GtkRange* range, { upper = (virtSize + pixelsPerLine - 1) / pixelsPerLine; page_size = winSize / pixelsPerLine; + if (page_size == 0) + page_size = 1; *lines = upper; *linesPerPage = page_size; } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index c00031bbb5..80d331716c 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -6011,6 +6011,8 @@ void wxWindowGTK::SetScrollbar(int orient, range = thumbVisible = 1; } + else if (thumbVisible <= 0) + thumbVisible = 1; g_signal_handlers_block_by_func( sb, (void*)gtk_scrollbar_value_changed, this);