From 5b3c1c46d7898f9dcd2330dea0dbfb317d164a2a Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sat, 5 Mar 2011 03:19:26 +0000 Subject: [PATCH] cleaner fix for #4066 --- macosx/PiecesView.m | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/macosx/PiecesView.m b/macosx/PiecesView.m index 5bdbf027e..9eb65f0a9 100644 --- a/macosx/PiecesView.m +++ b/macosx/PiecesView.m @@ -69,7 +69,17 @@ enum { [self clearView]; - fTorrent = torrent; + fTorrent = (torrent && ![torrent isMagnet]) ? torrent : nil; + if (fTorrent) + { + //determine relevant values + fNumPieces = MIN([fTorrent pieceCount], MAX_ACROSS * MAX_ACROSS); + fAcross = ceil(sqrt(fNumPieces)); + + const CGFloat width = [self bounds].size.width; + fWidth = (width - (fAcross + 1) * BETWEEN) / fAcross; + fExtraBorder = (width - ((fWidth + BETWEEN) * fAcross + BETWEEN)) / 2; + } NSImage * back = [[NSImage alloc] initWithSize: [self bounds].size]; [back lockFocus]; @@ -94,23 +104,13 @@ enum - (void) updateView { - if (!fTorrent || [fTorrent isMagnet]) + if (!fTorrent) return; //determine if first time const BOOL first = fPieces == NULL; if (first) - { - //determine relevant values - fNumPieces = MIN([fTorrent pieceCount], MAX_ACROSS * MAX_ACROSS); - fAcross = ceil(sqrt(fNumPieces)); - - const CGFloat width = [self bounds].size.width; - fWidth = (width - (fAcross + 1) * BETWEEN) / fAcross; - fExtraBorder = (width - ((fWidth + BETWEEN) * fAcross + BETWEEN)) / 2; - fPieces = (int8_t *)tr_malloc(fNumPieces * sizeof(int8_t)); - } int8_t * pieces = NULL; float * piecesPercent = NULL;