]> granicus.if.org Git - transmission/commitdiff
#5121 Stopped torrents resume after sleep automatically.
authorMitchell Livingston <livings124@transmissionbt.com>
Sun, 4 Nov 2012 19:28:51 +0000 (19:28 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Sun, 4 Nov 2012 19:28:51 +0000 (19:28 +0000)
macosx/Controller.m

index 47dafa39d3a655057e56bd485e4a6db0703e15a6..4a99fc5d740ca25b1d7418db5a23bb8fffc0a000 100644 (file)
@@ -4465,19 +4465,26 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     switch (messageType)
     {
         case kIOMessageSystemWillSleep:
-            //if there are any running transfers, wait 15 seconds for them to stop
+        {
+            //stop all transfers (since some are active) before going to sleep and remember to resume when we wake up
+            BOOL anyActive = NO;
             for (Torrent * torrent in fTorrents)
+            {
                 if ([torrent isActive])
-                {
-                    //stop all transfers (since some are active) before going to sleep and remember to resume when we wake up
-                    for (Torrent * torrent in fTorrents)
-                        [torrent sleep];
-                    sleep(15);
-                    break;
-                }
-
+                    anyActive = YES;
+                [torrent sleep]; //have to call on all, regardless if they are active
+            }
+            
+            //if there are any running transfers, wait 15 seconds for them to stop
+            if (anyActive)
+            {
+                sleep(15);
+                break;
+            }
+            
             IOAllowPowerChange(fRootPort, (long) messageArgument);
             break;
+        }
 
         case kIOMessageCanSystemSleep:
             if ([fDefaults boolForKey: @"SleepPrevent"])