Changeset 12100


Ignore:
Timestamp:
Mar 5, 2011, 3:19:26 AM (11 years ago)
Author:
livings124
Message:

cleaner fix for #4066

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/PiecesView.m

    r12048 r12100  
    7070    [self clearView];
    7171   
    72     fTorrent = torrent;
     72    fTorrent = (torrent && ![torrent isMagnet]) ? torrent : nil;
     73    if (fTorrent)
     74    {
     75        //determine relevant values
     76        fNumPieces = MIN([fTorrent pieceCount], MAX_ACROSS * MAX_ACROSS);
     77        fAcross = ceil(sqrt(fNumPieces));
     78       
     79        const CGFloat width = [self bounds].size.width;
     80        fWidth = (width - (fAcross + 1) * BETWEEN) / fAcross;
     81        fExtraBorder = (width - ((fWidth + BETWEEN) * fAcross + BETWEEN)) / 2;
     82    }
    7383   
    7484    NSImage * back = [[NSImage alloc] initWithSize: [self bounds].size];
     
    95105- (void) updateView
    96106{
    97     if (!fTorrent || [fTorrent isMagnet])
     107    if (!fTorrent)
    98108        return;
    99109   
     
    101111    const BOOL first = fPieces == NULL;
    102112    if (first)
    103     {
    104         //determine relevant values
    105         fNumPieces = MIN([fTorrent pieceCount], MAX_ACROSS * MAX_ACROSS);
    106         fAcross = ceil(sqrt(fNumPieces));
    107        
    108         const CGFloat width = [self bounds].size.width;
    109         fWidth = (width - (fAcross + 1) * BETWEEN) / fAcross;
    110         fExtraBorder = (width - ((fWidth + BETWEEN) * fAcross + BETWEEN)) / 2;
    111        
    112113        fPieces = (int8_t *)tr_malloc(fNumPieces * sizeof(int8_t));
    113     }
    114114
    115115    int8_t * pieces = NULL;
Note: See TracChangeset for help on using the changeset viewer.