Changeset 7144


Ignore:
Timestamp:
Nov 23, 2008, 5:40:35 PM (12 years ago)
Author:
charles
Message:

(1.4x libT) backport #1476: crash on exit when stats window is open

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.4x/libtransmission/stats.c

    r6896 r7144  
    1111 */
    1212
    13 #include <assert.h>
    14 
    1513#include "transmission.h"
    1614#include "bencode.h"
     
    2220****
    2321***/
     22
     23static struct tr_session_stats STATS_INIT = { 0.0f, 0, 0, 0, 0, 0 };
    2424
    2525struct tr_stats_handle
     
    120120tr_statsClose( tr_handle * handle )
    121121{
    122     tr_session_stats cumulative;
     122    tr_session_stats cumulative = STATS_INIT;
    123123
    124124    tr_sessionGetCumulativeStats( handle, &cumulative );
     
    132132getStats( const tr_handle * handle )
    133133{
    134     return handle->sessionStats;
     134    return handle ? handle->sessionStats : NULL;
    135135}
    136136
     
    164164{
    165165    const struct tr_stats_handle * stats = getStats( handle );
    166 
    167     assert( stats );
    168     *setme = stats->single;
    169     setme->secondsActive = time( NULL ) - stats->startTime;
    170     updateRatio( setme );
     166    if( stats )
     167    {
     168        *setme = stats->single;
     169        setme->secondsActive = time( NULL ) - stats->startTime;
     170        updateRatio( setme );
     171    }
    171172}
    172173
     
    176177{
    177178    const struct tr_stats_handle * stats = getStats( handle );
    178     tr_session_stats               current;
    179 
    180     assert( stats );
    181     tr_sessionGetStats( handle, &current );
    182     addStats( setme, &stats->old, &current );
     179    tr_session_stats current = STATS_INIT;
     180
     181    if( stats )
     182    {
     183        tr_sessionGetStats( handle, &current );
     184        addStats( setme, &stats->old, &current );
     185    }
    183186}
    184187
Note: See TracChangeset for help on using the changeset viewer.