Overflow on widgets, better fix ?

Started by
0 comments, last by Alundra 5 years, 10 months ago

Hi,
I saw an overflow bug on widgets code, I noticed it on the uint32 version when slide down with mouse when it was 0, then I saw it happens also for the maximum value.
So I added a fix but I would know if you think about a better fix because I also have an int32 and double version of the widget and could be better to fix overflow here too.
 


const int Delta = event->globalPos().x() - m_LastPos.x();
if( ( Delta > 0 ) && ( value() < getMaximum() ) )
  setValue( value() + min( Delta * singleStep(), getMaximum() - value() ) );
else if( ( Delta < 0 ) && ( value() > getMinimum() ) )
  setValue( value() - min( -Delta * singleStep(), value() - getMinimum() ) );


Thanks !

This topic is closed to new replies.

Advertisement