mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
(trunk gtk,qt) fix possible division by zero in the torrent properties dialog
This commit is contained in:
parent
58ba65f55b
commit
4658ad9c66
2 changed files with 3 additions and 2 deletions
|
@ -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 )
|
||||
|
|
|
@ -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 ) )
|
||||
|
|
Loading…
Reference in a new issue