diff --git a/macosx/Controller.m b/macosx/Controller.m index 6fd55ee2e..70c898d74 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -302,7 +302,7 @@ static void sleepCallBack(void * controller, io_service_t y, - (void) applicationWillTerminate: (NSNotification *) notification { - // Stop updating the interface + //stop updating the interface [fTimer invalidate]; //save history @@ -320,9 +320,9 @@ static void sleepCallBack(void * controller, io_service_t y, if (fUpdateInProgress) return; - //stop running torrents and wait for them to stop (5 seconds timeout) - [fTorrents makeObjectsPerformSelector: @selector(stopTransfer)]; - + //stop running transfers and wait for them to stop (5 seconds timeout) + [fTorrents makeObjectsPerformSelector: @selector(stopTransferForQuit)]; + NSDate * start = [NSDate date]; Torrent * torrent; while ([fTorrents count] > 0) diff --git a/macosx/Torrent.h b/macosx/Torrent.h index e3ea792f5..2e5e303e6 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -66,6 +66,7 @@ - (void) update; - (void) startTransfer; - (void) stopTransfer; +- (void) stopTransferForQuit; - (void) removeForever; - (void) sleep; - (void) wakeUp; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 86cff2a41..749e10fdf 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -74,7 +74,7 @@ NSString * paused; if (!(paused = [history objectForKey: @"Paused"]) || [paused isEqualToString: @"NO"]) - [self startTransfer]; + tr_torrentStart(fHandle); } return self; } @@ -251,6 +251,12 @@ } } +- (void) stopTransferForQuit +{ + if ([self isActive]) + tr_torrentStop(fHandle); +} + - (void) removeForever { if (fPrivateTorrent) @@ -607,6 +613,7 @@ fWaitToStart = waitToStart ? [waitToStart boolValue] : ![[fDefaults stringForKey: @"StartSetting"] isEqualToString: @"Manual"]; + fOrderValue = orderValue ? [orderValue intValue] : tr_torrentCount(fLib) - 1; NSString * fileType = fInfo->multifile ? NSFileTypeForHFSTypeCode('fldr') : [[self name] pathExtension]; fIcon = [[NSWorkspace sharedWorkspace] iconForFileType: fileType]; @@ -617,8 +624,6 @@ fProgressString = [[NSMutableString alloc] initWithCapacity: 50]; fStatusString = [[NSMutableString alloc] initWithCapacity: 75]; - - fOrderValue = orderValue ? [orderValue intValue] : tr_torrentCount(fLib) - 1; [self update]; return self;