(trunk gtk,qt) fix possible division by zero in the torrent properties dialog

This commit is contained in:
Charles Kerr 2009-06-30 22:27:22 +00:00
parent 58ba65f55b
commit 4658ad9c66
2 changed files with 3 additions and 2 deletions

View File

@ -791,7 +791,7 @@ refreshInfo( struct DetailsImpl * di, tr_torrent ** torrents, int n )
str = none;
else {
char unver[64], total[64];
const double ratio = ( 100.0 * ( haveValid + haveUnchecked ) ) / leftUntilDone;
const double ratio = 100.0 * ( leftUntilDone ? ( haveValid + haveUnchecked ) / leftUntilDone : 1 );
tr_strlsize( total, haveUnchecked + haveValid, sizeof( total ) );
tr_strlsize( unver, haveUnchecked, sizeof( unver ) );
if( haveUnchecked )

View File

@ -267,7 +267,8 @@ Details :: refresh( )
if( !haveVerified && !haveUnverified )
string = none;
else {
QString pct = locale.toString( 100.0*((sizeWhenDone-leftUntilDone)/sizeWhenDone), 'f', 2 );
const double d = 100.0 * ( sizeWhenDone ? ( sizeWhenDone - leftUntilDone ) / sizeWhenDone : 1 );
QString pct = locale.toString( d, 'f', 2 );
if( !haveUnverified )
string = tr( "%1 (%2%)" )
.arg( Utils :: sizeToString( haveVerified + haveUnverified ) )