security fix to xprogressbar display

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2354 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-02-17 20:22:52 +00:00
parent f1a056dd93
commit dd114e54d7

View File

@ -196,22 +196,25 @@ void xProgressBar::paint()
uint32_t ss = _pinfo.nb_chunks ; uint32_t ss = _pinfo.nb_chunks ;
if(ss > 1) // for small files we use a more progressive display if(ss > 1) // for small files we use a more progressive display
for(int i=0;i<ss;++i) {
{ if(!_pinfo.cmap._map.empty())
int j=0 ; for(int i=0;i<ss;++i)
while(i+j<ss && _pinfo.cmap[i+j])
++j ;
float o = std::min(1.0f,j/(float)ss*width) ;
if(j>0 && o >= 1.0f) // limits the number of regions drawn
{ {
painter->setOpacity(o) ; int j=0 ;
painter->drawRect(rect.x() + hSpan+(int)rint(i*width/(float)ss), rect.y() + vSpan, (int)ceil(j*width/(float)ss), rect.height() - 1 - vSpan * 2); while(i+j<ss && _pinfo.cmap[i+j])
} ++j ;
i += j ; float o = std::min(1.0f,j/(float)ss*width) ;
}
if(j>0 && o >= 1.0f) // limits the number of regions drawn
{
painter->setOpacity(o) ;
painter->drawRect(rect.x() + hSpan+(int)rint(i*width/(float)ss), rect.y() + vSpan, (int)ceil(j*width/(float)ss), rect.height() - 1 - vSpan * 2);
}
i += j ;
}
}
else else
{ {
// calculate progress value // calculate progress value