]> granicus.if.org Git - transmission/commitdiff
(trunk) #4066 Fix the pieces view for magnet links
authorMitchell Livingston <livings124@transmissionbt.com>
Sat, 26 Feb 2011 15:13:35 +0000 (15:13 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Sat, 26 Feb 2011 15:13:35 +0000 (15:13 +0000)
macosx/PiecesView.m

index d502c1cea7590dcf2f9db978f352ddcf6a0d7f7b..5bdbf027e043399e4ebd7b1d51da11ba4d79d34b 100644 (file)
@@ -70,16 +70,6 @@ enum
     [self clearView];
     
     fTorrent = torrent;
-    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];
@@ -104,13 +94,23 @@ enum
 
 - (void) updateView
 {
-    if (!fTorrent)
+    if (!fTorrent || [fTorrent isMagnet])
         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;