Jump to content
  • Advertisement
Sign in to follow this  
Alundra

Overflow on widgets, better fix ?

Recommended Posts

Posted (edited)

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 !

Edited by Alundra

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!