1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00

fix: crash on launch from tapping on a notification (#5280)

This commit is contained in:
Cœur 2023-03-24 21:04:30 +08:00 committed by GitHub
parent a216bd7cec
commit 1b81883e66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -884,10 +884,24 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
andEventID:kAEOpenContents]; andEventID:kAEOpenContents];
//if we were opened from a user notification, do the corresponding action //if we were opened from a user notification, do the corresponding action
NSUserNotification* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey]; if (@available(macOS 10.14, *))
if (launchNotification)
{ {
[self userNotificationCenter:NSUserNotificationCenter.defaultUserNotificationCenter didActivateNotification:launchNotification]; UNNotificationResponse* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey];
if (launchNotification)
{
[self userNotificationCenter:UNUserNotificationCenter.currentNotificationCenter
didReceiveNotificationResponse:launchNotification withCompletionHandler:^{
}];
}
}
else
{
NSUserNotification* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey];
if (launchNotification)
{
[self userNotificationCenter:NSUserNotificationCenter.defaultUserNotificationCenter
didActivateNotification:launchNotification];
}
} }
//auto importing //auto importing
@ -2385,6 +2399,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
{ {
if (!response.notification.request.content.userInfo.count) if (!response.notification.request.content.userInfo.count)
{ {
completionHandler();
return; return;
} }
@ -2396,6 +2411,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
{ {
[self didActivateNotificationByActionShowWithUserInfo:response.notification.request.content.userInfo]; [self didActivateNotificationByActionShowWithUserInfo:response.notification.request.content.userInfo];
} }
completionHandler();
} }
- (void)userNotificationCenter:(NSUserNotificationCenter*)center didActivateNotification:(NSUserNotification*)notification - (void)userNotificationCenter:(NSUserNotificationCenter*)center didActivateNotification:(NSUserNotification*)notification