From cfdd4127b51465c1e011a421b18921d1edd3dfbd Mon Sep 17 00:00:00 2001 From: Kvaz1r Date: Tue, 28 Sep 2021 17:36:10 +0300 Subject: [PATCH] Fix handling wxSHOW_SB_ALWAYS in SetScrollbar() in wxUniv Range may be -1 when wxSHOW_SB_ALWAYS is used, see wxScrollHelper::DoAdjustScrollbar(), so check for it to avoid spurious asserts in this case. Closes https://github.com/wxWidgets/wxWidgets/pull/2540 --- src/univ/winuniv.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/univ/winuniv.cpp b/src/univ/winuniv.cpp index 4a291ea3bd..4d7afacc2f 100644 --- a/src/univ/winuniv.cpp +++ b/src/univ/winuniv.cpp @@ -915,7 +915,7 @@ void wxWindow::SetScrollbar(int orient, bool refresh) { #if wxUSE_SCROLLBAR - wxASSERT_MSG( pageSize <= range, + wxASSERT_MSG( (range == -1 || pageSize <= range), wxT("page size can't be greater than range") ); bool hasClientSizeChanged = false; @@ -958,10 +958,10 @@ void wxWindow::SetScrollbar(int orient, if ( scrollbar ) { // wxALWAYS_SHOW_SB only applies to the vertical scrollbar - if ( (orient & wxVERTICAL) && (GetWindowStyle() & wxALWAYS_SHOW_SB) ) + if ( range == -1 || ((orient & wxVERTICAL) && (GetWindowStyle() & wxALWAYS_SHOW_SB)) ) { // just disable the scrollbar - scrollbar->SetScrollbar(pos, pageSize, range, pageSize, refresh); + scrollbar->SetScrollbar(pos, pageSize, range == -1 ? 0 : range, pageSize, refresh); scrollbar->Disable(); } else // really remove the scrollbar