From 1527698de489062f7771371e133ad321667470a6 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sat, 2 Jan 2021 23:29:08 -0500 Subject: [PATCH] Fix a few deprecation warnings --- macosx/AboutWindowController.m | 2 +- macosx/BlocklistDownloaderViewController.m | 2 +- macosx/Controller.m | 11 ++++++++++- macosx/CreatorWindowController.m | 2 +- macosx/PrefsController.m | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/macosx/AboutWindowController.m b/macosx/AboutWindowController.m index 0e13dc445..740bbbc04 100644 --- a/macosx/AboutWindowController.m +++ b/macosx/AboutWindowController.m @@ -73,7 +73,7 @@ AboutWindowController * fAboutBoxInstance = nil; [fLicenseView setString: licenseText]; [fLicenseCloseButton setTitle: NSLocalizedString(@"OK", "About window -> license close button")]; - [NSApp beginSheet: fLicenseSheet modalForWindow: [self window] modalDelegate: nil didEndSelector: nil contextInfo: nil]; + [self.window beginSheet: fLicenseSheet completionHandler:nil]; } - (IBAction) hideLicense: (id) sender diff --git a/macosx/BlocklistDownloaderViewController.m b/macosx/BlocklistDownloaderViewController.m index 887df8bb4..db2a4bdb3 100644 --- a/macosx/BlocklistDownloaderViewController.m +++ b/macosx/BlocklistDownloaderViewController.m @@ -146,7 +146,7 @@ BlocklistDownloaderViewController * fBLViewController = nil; BlocklistDownloader * downloader = [BlocklistDownloader downloader]; [downloader setViewController: self]; //do before showing the sheet to ensure it doesn't slide out with placeholder text - [NSApp beginSheet: fStatusWindow modalForWindow: [fPrefsController window] modalDelegate: nil didEndSelector: nil contextInfo: nil]; + [fPrefsController.window beginSheet: fStatusWindow completionHandler:nil]; } @end diff --git a/macosx/Controller.m b/macosx/Controller.m index e3c7679f7..1ac112f26 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1319,7 +1319,16 @@ static void removeKeRangerRansomware() { fUrlSheetController = [[URLSheetWindowController alloc] initWithController: self]; - [NSApp beginSheet: [fUrlSheetController window] modalForWindow: fWindow modalDelegate: self didEndSelector: @selector(urlSheetDidEnd:returnCode:contextInfo:) contextInfo: nil]; + [fWindow beginSheet: fUrlSheetController.window completionHandler:^(NSModalResponse returnCode) { + if (returnCode == 1) + { + NSString * urlString = [fUrlSheetController urlString]; + dispatch_async(dispatch_get_main_queue(), ^{ + [self openURL: urlString]; + }); + } + fUrlSheetController = nil; + }]; } } diff --git a/macosx/CreatorWindowController.m b/macosx/CreatorWindowController.m index 4f03f5196..4d6900747 100644 --- a/macosx/CreatorWindowController.m +++ b/macosx/CreatorWindowController.m @@ -465,7 +465,7 @@ NSMutableSet *creatorWindowControllerSet = nil; [panel setMessage: NSLocalizedString(@"Select a file or folder for the torrent file.", "Create torrent -> select file")]; - BOOL success = [panel runModal] == NSOKButton; + BOOL success = [panel runModal] == NSModalResponseOK; return success ? [panel URLs][0] : nil; } diff --git a/macosx/PrefsController.m b/macosx/PrefsController.m index cf1a6e963..ee7b36535 100644 --- a/macosx/PrefsController.m +++ b/macosx/PrefsController.m @@ -709,7 +709,7 @@ + (NSInteger) dateToTimeSum: (NSDate *) date { NSCalendar * calendar = [NSCalendar currentCalendar]; - NSDateComponents * components = [calendar components: NSHourCalendarUnit | NSMinuteCalendarUnit fromDate: date]; + NSDateComponents * components = [calendar components: NSCalendarUnitHour | NSCalendarUnitMinute fromDate: date]; return [components hour] * 60 + [components minute]; }