don't leave evtType uninitialized in gtk_slider_callback() (thanks coverity checker)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37860 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -52,25 +52,34 @@ static inline int AdjustValueToInt(double x)
|
|||||||
static void
|
static void
|
||||||
ProcessScrollEvent(wxSlider *win, wxEventType evtType, double dvalue)
|
ProcessScrollEvent(wxSlider *win, wxEventType evtType, double dvalue)
|
||||||
{
|
{
|
||||||
int orient = win->GetWindowStyleFlag() & wxSL_VERTICAL ? wxVERTICAL
|
const int orient = win->HasFlag(wxSL_VERTICAL) ? wxVERTICAL
|
||||||
: wxHORIZONTAL;
|
: wxHORIZONTAL;
|
||||||
|
|
||||||
int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5);
|
const int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5);
|
||||||
wxScrollEvent event( evtType, win->GetId(), value, orient );
|
|
||||||
event.SetEventObject( win );
|
|
||||||
win->GetEventHandler()->ProcessEvent( event );
|
|
||||||
|
|
||||||
if ( evtType != wxEVT_SCROLL_THUMBTRACK )
|
// if we have any "special" event (i.e. the value changed by a line or a
|
||||||
|
// page), send this specific event first
|
||||||
|
if ( evtType != wxEVT_NULL )
|
||||||
{
|
{
|
||||||
wxScrollEvent event2(wxEVT_SCROLL_CHANGED, win->GetId(), value, orient);
|
wxScrollEvent event( evtType, win->GetId(), value, orient );
|
||||||
event2.SetEventObject( win );
|
event.SetEventObject( win );
|
||||||
win->GetEventHandler()->ProcessEvent( event2 );
|
win->GetEventHandler()->ProcessEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() );
|
// but, in any case, except if we're dragging the slider (and so the change
|
||||||
cevent.SetEventObject( win );
|
// is not definitive), send a generic "changed" event
|
||||||
cevent.SetInt( value );
|
if ( evtType != wxEVT_SCROLL_THUMBTRACK )
|
||||||
win->GetEventHandler()->ProcessEvent( cevent );
|
{
|
||||||
|
wxScrollEvent event(wxEVT_SCROLL_CHANGED, win->GetId(), value, orient);
|
||||||
|
event.SetEventObject( win );
|
||||||
|
win->GetEventHandler()->ProcessEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
|
// and also generate a command event for compatibility
|
||||||
|
wxCommandEvent event( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() );
|
||||||
|
event.SetEventObject( win );
|
||||||
|
event.SetInt( value );
|
||||||
|
win->GetEventHandler()->ProcessEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -107,6 +116,8 @@ static void gtk_slider_callback( GtkAdjustment *adjust,
|
|||||||
evtType = wxEVT_SCROLL_TOP;
|
evtType = wxEVT_SCROLL_TOP;
|
||||||
else if ( AreSameAdjustValues(adjust->value, adjust->upper) )
|
else if ( AreSameAdjustValues(adjust->value, adjust->upper) )
|
||||||
evtType = wxEVT_SCROLL_BOTTOM;
|
evtType = wxEVT_SCROLL_BOTTOM;
|
||||||
|
else
|
||||||
|
evtType = wxEVT_NULL; // wxEVT_SCROLL_CHANGED will still be generated
|
||||||
|
|
||||||
ProcessScrollEvent(win, evtType, dvalue);
|
ProcessScrollEvent(win, evtType, dvalue);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user