Prevent UI thread lockup when drawing hideously large progress bars for no reason.

This commit is contained in:
Simon Robertshaw 2012-09-16 17:57:41 +01:00
parent bd02c36426
commit e52e9ce91c

View File

@ -33,6 +33,8 @@ void ProgressBar::Draw(const Point & screenPos)
{
if(progress > 0)
{
if(progress > 100)
progress = 100;
float size = float(Size.X-4)*(float(progress)/100.0f); // TIL...
size = std::min(std::max(size, 0.0f), float(Size.X-4));
g->fillrect(screenPos.X + 2, screenPos.Y + 2, size, Size.Y-4, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255);