diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 1f84de1e3..3f913d96a 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -381,14 +381,14 @@ static void removeKeRangerRansomware() [NSValueTransformer setValueTransformer:iconTransformer forName:@"ExpandedPathToIconTransformer"]; } -void onStartQueue(tr_session* /*session*/, tr_torrent* tor, void* vself) +void onStartQueue(tr_session* /*session*/, tr_torrent* /*tor*/, void* /*vself*/) { - auto* controller = (__bridge Controller*)(vself); - auto const hashstr = @(tr_torrentView(tor).hash_string); - dispatch_async(dispatch_get_main_queue(), ^{ - auto* const torrent = [controller torrentForHash:hashstr]; - [torrent startQueue]; + //posting asynchronously with coalescing to prevent stack overflow on lots of torrents changing state at the same time + [NSNotificationQueue.defaultQueue enqueueNotification:[NSNotification notificationWithName:@"UpdateTorrentsState" object:nil] + postingStyle:NSPostASAP + coalesceMask:NSNotificationCoalescingOnName + forModes:nil]; }); } @@ -812,8 +812,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool [nc addObserver:self.fWindow selector:@selector(makeKeyWindow) name:@"MakeWindowKey" object:nil]; -#warning rename - [nc addObserver:self selector:@selector(fullUpdateUI) name:@"UpdateQueue" object:nil]; + [nc addObserver:self selector:@selector(fullUpdateUI) name:@"UpdateTorrentsState" object:nil]; [nc addObserver:self selector:@selector(applyFilter) name:@"ApplyFilter" object:nil]; diff --git a/macosx/FileOutlineController.mm b/macosx/FileOutlineController.mm index 1a4598f7a..c5166fb94 100644 --- a/macosx/FileOutlineController.mm +++ b/macosx/FileOutlineController.mm @@ -463,7 +463,7 @@ typedef NS_ENUM(NSUInteger, FilePriorityMenuTag) { // [FileRenameSheetController presentSheetForTorrent:torrent modalForWindow:self.fOutline.window completionHandler:^(BOOL didRename) { if (didRename) { - [NSNotificationCenter.defaultCenter postNotificationName:@"UpdateQueue" object:self]; + [NSNotificationCenter.defaultCenter postNotificationName:@"UpdateTorrentsState" object:nil]; [NSNotificationCenter.defaultCenter postNotificationName:@"ResetInspector" object:self userInfo:@{ @"Torrent" : torrent }]; } diff --git a/macosx/PrefsController.mm b/macosx/PrefsController.mm index 635d07342..e9699a001 100644 --- a/macosx/PrefsController.mm +++ b/macosx/PrefsController.mm @@ -879,7 +879,7 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/"; tr_sessionSetQueueEnabled(self.fHandle, TR_UP, [self.fDefaults boolForKey:@"QueueSeed"]); //handle if any transfers switch from queued to paused - [NSNotificationCenter.defaultCenter postNotificationName:@"UpdateQueue" object:self]; + [NSNotificationCenter.defaultCenter postNotificationName:@"UpdateTorrentsState" object:nil]; } - (void)setQueueNumber:(id)sender diff --git a/macosx/Torrent.h b/macosx/Torrent.h index 777fbc183..9a9cda111 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -42,7 +42,6 @@ extern NSString* const kTorrentDidChangeGroupNotification; - (void)startTransfer; - (void)startMagnetTransferAfterMetaDownload; - (void)stopTransfer; -- (void)startQueue; - (void)sleep; - (void)wakeUp; - (void)idleLimitHit; diff --git a/macosx/Torrent.mm b/macosx/Torrent.mm index 81a0ce0c5..212d1f069 100644 --- a/macosx/Torrent.mm +++ b/macosx/Torrent.mm @@ -251,7 +251,7 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error* error) if (wasTransmitting != self.transmitting) { //posting asynchronously with coalescing to prevent stack overflow on lots of torrents changing state at the same time - [NSNotificationQueue.defaultQueue enqueueNotification:[NSNotification notificationWithName:@"UpdateQueue" object:self] + [NSNotificationQueue.defaultQueue enqueueNotification:[NSNotification notificationWithName:@"UpdateTorrentsState" object:nil] postingStyle:NSPostASAP coalesceMask:NSNotificationCoalescingOnName forModes:nil]; @@ -1982,11 +1982,6 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error* error) }]; } -- (void)startQueue -{ - [NSNotificationCenter.defaultCenter postNotificationName:@"UpdateQueue" object:self]; -} - - (void)completenessChange:(tr_completeness)status wasRunning:(BOOL)wasRunning { self.fStat = tr_torrentStat(self.fHandle); //don't call update yet to avoid auto-stop