]> granicus.if.org Git - transmission/commitdiff
#3320 When a download completes at the same time seeding completes, still show a...
authorMitchell Livingston <livings124@transmissionbt.com>
Fri, 25 Jun 2010 22:19:28 +0000 (22:19 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Fri, 25 Jun 2010 22:19:28 +0000 (22:19 +0000)
macosx/Controller.m
macosx/Torrent.m

index a813fd16b90dc99f1ddf687c5dad9e32159777e5..683613e9db4a5436fb95c3e9b05935676916fd54 100644 (file)
@@ -1888,7 +1888,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 {
     Torrent * torrent = [notification object];
     
-    if ([torrent isActive])
+    if ([[[notification userInfo] objectForKey: @"WasRunning"] boolValue])
     {
         if (!fSoundPlaying && [fDefaults boolForKey: @"PlayDownloadSound"])
         {
@@ -1918,7 +1918,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         [[NSDistributedNotificationCenter defaultCenter] postNotificationName: @"com.apple.DownloadFileFinished"
             object: [torrent dataLocation]];
         
-        if ([fDefaults boolForKey: @"QueueSeed"] && [self numToStartFromQueue: NO] == 0)
+        if ([torrent isActive] && [fDefaults boolForKey: @"QueueSeed"] && [self numToStartFromQueue: NO] == 0)
         {
             [torrent stopTransfer];
             [torrent setWaitToStart: YES];
@@ -1931,13 +1931,10 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 - (void) torrentRestartedDownloading: (NSNotification *) notification
 {
     Torrent * torrent = [notification object];
-    if ([torrent isActive])
+    if ([torrent isActive] && [fDefaults boolForKey: @"Queue"] && [self numToStartFromQueue: YES] == 0)
     {
-        if ([fDefaults boolForKey: @"Queue"] && [self numToStartFromQueue: YES] == 0)
-        {
-            [torrent stopTransfer];
-            [torrent setWaitToStart: YES];
-        }
+        [torrent stopTransfer];
+        [torrent setWaitToStart: YES];
     }
     
     [self updateTorrentsInQueue];
index 5eceb71a21f90656bb66d2ba23e87a6eaef3bcc1..fcf7be7b8bf0ef2e6bc91eafdc3004ccdd875019 100644 (file)
@@ -43,7 +43,7 @@
 - (void) insertPath: (NSMutableArray *) components forParent: (FileListNode *) parent fileSize: (uint64_t) size
     index: (NSInteger) index flatList: (NSMutableArray *) flatFileList;
 
-- (void) completenessChange: (NSNumber *) status;
+- (void) completenessChange: (NSDictionary *) statusInfo;
 - (void) ratioLimitHit;
 - (void) metadataRetrieved;
 
 
 @end
 
-void completenessChangeCallback(tr_torrent * torrent, tr_completeness status, void * torrentData)
+void completenessChangeCallback(tr_torrent * torrent, tr_completeness status, tr_bool wasRunning, void * torrentData)
 {
-    [(Torrent *)torrentData performSelectorOnMainThread: @selector(completenessChange:)
-        withObject: [[NSNumber alloc] initWithInt: status] waitUntilDone: NO];
+    NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt: status], @"Status",
+                            [NSNumber numberWithBool: wasRunning], @"WasRunning", nil];
+    [(Torrent *)torrentData performSelectorOnMainThread: @selector(completenessChange:) withObject: dict waitUntilDone: NO];
 }
 
 void ratioLimitHitCallback(tr_torrent * torrent, void * torrentData)
@@ -1743,22 +1744,24 @@ int trashDataFile(const char * filename)
 }
 
 //status has been retained
-- (void) completenessChange: (NSNumber *) status
+- (void) completenessChange: (NSDictionary *) statusInfo
 {
     fStat = tr_torrentStat(fHandle); //don't call update yet to avoid auto-stop
     
-    switch ([status intValue])
+    switch ([[statusInfo objectForKey: @"Status"] intValue])
     {
         case TR_SEED:
         case TR_PARTIAL_SEED:
-            [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self];
+            //simpler to create a new dictionary than to use statusInfo - avoids retention chicanery
+            [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self
+                userInfo: [NSDictionary dictionaryWithObject: [statusInfo objectForKey: @"WasRunning"] forKey: @"WasRunning"]];
             break;
         
         case TR_LEECH:
             [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentRestartedDownloading" object: self];
             break;
     }
-    [status release];
+    [statusInfo release];
     
     [self update];
     [self updateTimeMachineExclude];