diff --git a/gtk/details.c b/gtk/details.c index 188d4facc..2e0d98796 100644 --- a/gtk/details.c +++ b/gtk/details.c @@ -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 ) diff --git a/qt/details.cc b/qt/details.cc index d7690fda4..a5983c2b6 100644 --- a/qt/details.cc +++ b/qt/details.cc @@ -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 ) )