From 56b14ed5d61247d3619c68ac60031fcab0fb0547 Mon Sep 17 00:00:00 2001 From: Patrick Wardle Date: Fri, 18 Nov 2022 17:21:56 -1000 Subject: [PATCH] improved update checks --- .../Application/PrefsWindowController.m | 2 +- Shared/Utilities.m | 53 ++++++++++++------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/Application/Application/PrefsWindowController.m b/Application/Application/PrefsWindowController.m index 851e6b8..fac2882 100644 --- a/Application/Application/PrefsWindowController.m +++ b/Application/Application/PrefsWindowController.m @@ -367,7 +367,7 @@ bail: case Update_NotSupported: //dbg msg - os_log_debug(logHandle, "update available, but not for this version of macOS"); + os_log_debug(logHandle, "update available, but not for this version of macOS."); //set label self.updateLabel.stringValue = [NSString stringWithFormat:@"Update available, but isn't supported on macOS %ld.%ld", NSProcessInfo.processInfo.operatingSystemVersion.majorVersion, NSProcessInfo.processInfo.operatingSystemVersion.minorVersion]; diff --git a/Shared/Utilities.m b/Shared/Utilities.m index 36f5c4f..35bfd50 100644 --- a/Shared/Utilities.m +++ b/Shared/Utilities.m @@ -969,33 +969,48 @@ bail: return icon; } -//wait until a window is non nil -// then make it modal +//wait till window non-nil +// then make that window modal void makeModal(NSWindowController* windowController) { - //wait up to 1 second window to be non-nil - // then make modal + //window + __block NSWindow* window = nil; + + //wait till non-nil + // then make window modal for(int i=0; i<20; i++) { - //can make it modal once we have a window - if(nil != windowController.window) - { - //make modal on main thread - dispatch_sync(dispatch_get_main_queue(), ^{ - - //modal - [[NSApplication sharedApplication] runModalForWindow:windowController.window]; - - }); + //grab window + dispatch_sync(dispatch_get_main_queue(), ^{ + + //grab + window = windowController.window; - //all done - break; + }); + + //nil? + // nap + if(nil == window) + { + //nap + [NSThread sleepForTimeInterval:0.05f]; + + //next + continue; } - //nap - [NSThread sleepForTimeInterval:0.05f]; + //have window? + // make it modal + dispatch_sync(dispatch_get_main_queue(), ^{ + + //modal + [[NSApplication sharedApplication] runModalForWindow:windowController.window]; + + }); - }//until 1 second + //done + break; + } return; }