check that we do have scrollbars before using them to avoid crashes when SetScrollXXX() methods are called for windows which are not scrollable
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46575 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -4126,9 +4126,8 @@ void wxWindowGTK::SetScrollbar(int orient,
|
|||||||
int range,
|
int range,
|
||||||
bool WXUNUSED(update))
|
bool WXUNUSED(update))
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
|
GtkRange * const sb = m_scrollBar[ScrollDirFromOrient(orient)];
|
||||||
wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
|
wxCHECK_RET( sb, _T("this window is not scrollable") );
|
||||||
wxCHECK_RET( m_wxwindow != m_widget, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") );
|
|
||||||
|
|
||||||
if (range > 0)
|
if (range > 0)
|
||||||
{
|
{
|
||||||
@@ -4145,7 +4144,7 @@ void wxWindowGTK::SetScrollbar(int orient,
|
|||||||
pos = range - thumbVisible;
|
pos = range - thumbVisible;
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
pos = 0;
|
pos = 0;
|
||||||
GtkAdjustment* adj = m_scrollBar[ScrollDirFromOrient(orient)]->adjustment;
|
GtkAdjustment * const adj = sb->adjustment;
|
||||||
adj->step_increment = 1;
|
adj->step_increment = 1;
|
||||||
adj->page_increment =
|
adj->page_increment =
|
||||||
adj->page_size = thumbVisible;
|
adj->page_size = thumbVisible;
|
||||||
@@ -4156,16 +4155,15 @@ void wxWindowGTK::SetScrollbar(int orient,
|
|||||||
|
|
||||||
void wxWindowGTK::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
|
void wxWindowGTK::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
|
const int dir = ScrollDirFromOrient(orient);
|
||||||
wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
|
GtkRange * const sb = m_scrollBar[dir];
|
||||||
wxCHECK_RET( m_wxwindow != m_widget, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") );
|
wxCHECK_RET( sb, _T("this window is not scrollable") );
|
||||||
|
|
||||||
// This check is more than an optimization. Without it, the slider
|
// This check is more than an optimization. Without it, the slider
|
||||||
// will not move smoothly while tracking when using wxScrollHelper.
|
// will not move smoothly while tracking when using wxScrollHelper.
|
||||||
if (GetScrollPos(orient) != pos)
|
if (GetScrollPos(orient) != pos)
|
||||||
{
|
{
|
||||||
const int dir = ScrollDirFromOrient(orient);
|
GtkAdjustment* adj = sb->adjustment;
|
||||||
GtkAdjustment* adj = m_scrollBar[dir]->adjustment;
|
|
||||||
const int max = int(adj->upper - adj->page_size);
|
const int max = int(adj->upper - adj->page_size);
|
||||||
if (pos > max)
|
if (pos > max)
|
||||||
pos = max;
|
pos = max;
|
||||||
@@ -4183,29 +4181,26 @@ void wxWindowGTK::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
|
|||||||
|
|
||||||
int wxWindowGTK::GetScrollThumb(int orient) const
|
int wxWindowGTK::GetScrollThumb(int orient) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") );
|
GtkRange * const sb = m_scrollBar[ScrollDirFromOrient(orient)];
|
||||||
wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") );
|
wxCHECK_MSG( sb, 0, _T("this window is not scrollable") );
|
||||||
wxCHECK_MSG( m_wxwindow != m_widget, 0, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") );
|
|
||||||
|
|
||||||
return int(m_scrollBar[ScrollDirFromOrient(orient)]->adjustment->page_size);
|
return int(sb->adjustment->page_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxWindowGTK::GetScrollPos( int orient ) const
|
int wxWindowGTK::GetScrollPos( int orient ) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") );
|
GtkRange * const sb = m_scrollBar[ScrollDirFromOrient(orient)];
|
||||||
wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") );
|
wxCHECK_MSG( sb, 0, _T("this window is not scrollable") );
|
||||||
wxCHECK_MSG( m_wxwindow != m_widget, 0, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") );
|
|
||||||
|
|
||||||
return int(m_scrollBar[ScrollDirFromOrient(orient)]->adjustment->value + 0.5);
|
return int(sb->adjustment->value + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxWindowGTK::GetScrollRange( int orient ) const
|
int wxWindowGTK::GetScrollRange( int orient ) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") );
|
GtkRange * const sb = m_scrollBar[ScrollDirFromOrient(orient)];
|
||||||
wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") );
|
wxCHECK_MSG( sb, 0, _T("this window is not scrollable") );
|
||||||
wxCHECK_MSG( m_wxwindow != m_widget, 0, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") );
|
|
||||||
|
|
||||||
return int(m_scrollBar[ScrollDirFromOrient(orient)]->adjustment->upper);
|
return int(sb->adjustment->upper);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if increment is the same as +/-x, allowing for some small
|
// Determine if increment is the same as +/-x, allowing for some small
|
||||||
|
Reference in New Issue
Block a user