mirror of
https://github.com/transmission/transmission
synced 2024-12-26 01:27:28 +00:00
fix: crash on launch from tapping on a notification (#5280)
This commit is contained in:
parent
a216bd7cec
commit
1b81883e66
1 changed files with 19 additions and 3 deletions
|
@ -884,10 +884,24 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
|
|||
andEventID:kAEOpenContents];
|
||||
|
||||
//if we were opened from a user notification, do the corresponding action
|
||||
NSUserNotification* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey];
|
||||
if (launchNotification)
|
||||
if (@available(macOS 10.14, *))
|
||||
{
|
||||
[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
|
||||
|
@ -2385,6 +2399,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
|
|||
{
|
||||
if (!response.notification.request.content.userInfo.count)
|
||||
{
|
||||
completionHandler();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2396,6 +2411,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
|
|||
{
|
||||
[self didActivateNotificationByActionShowWithUserInfo:response.notification.request.content.userInfo];
|
||||
}
|
||||
completionHandler();
|
||||
}
|
||||
|
||||
- (void)userNotificationCenter:(NSUserNotificationCenter*)center didActivateNotification:(NSUserNotification*)notification
|
||||
|
|
Loading…
Reference in a new issue