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
This commit is contained in:
Kvaz1r
2021-09-28 17:36:10 +03:00
committed by Vadim Zeitlin
parent 746da37c4d
commit cfdd4127b5

View File

@@ -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