From 1e34d5a78b939df88da9fcf4b0a8876c0173d0eb Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sun, 4 Nov 2012 19:28:51 +0000 Subject: [PATCH] #5121 Stopped torrents resume after sleep automatically. --- macosx/Controller.m | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index 47dafa39d..4a99fc5d7 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -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"]) -- 2.49.0