@@ -857,6 +857,25 @@ - (void)stealObjectsFromAppleAlerts {
857
857
858
858
// Steal the icon. (Could also get this from NSBundle I suppose.)
859
859
NSImage * rawIcon = [nsAlert icon ] ;
860
+
861
+ /* The next line was added to fix a crash during subsequent app quitting
862
+ which started in macOS 12:
863
+ * Assertion failed: (![[NSApp _openWindows] NS_containsObjectIdenticalTo:self]), function -[NSWindow dealloc], file NSWindow.m, line 1579
864
+ I only noticed this if I quit after licensing. After licensing, there
865
+ are two SSYAlert objects created and destroyed in succession. The first
866
+ one shows the downloaded License Information and the second one I forgot
867
+ what it shows. Anyhow, I noticted that if I quit the app immediately
868
+ after dismissing those two SSYAlerts in succession, the array returned by
869
+ [NSApplication windows] included two _NSAlertPanel which I found were
870
+ attached to the `nsAlert` created here. Even after the fix, these two
871
+ _NSAlertPanel objects remain in [NSApplication windows] for some time, but
872
+ will be found to be gone later if you do not quit immediately. Although
873
+ sending either -close or -performClose: fixed the assertion+crash, I
874
+ decided on the former since the latter calls NSBeep, probably because
875
+ the "window doesn’t have a close button", as explained in documentation
876
+ of -[NSWindow performClose:]. */
877
+ [nsAlert.window close ];
878
+
860
879
#if !__has_feature(objc_arc)
861
880
[nsAlert release ] ;
862
881
#endif
@@ -2403,14 +2422,22 @@ - (void)doLayoutError:(NSError*)error {
2403
2422
[self setTitleText: title] ;
2404
2423
}
2405
2424
2406
- // Set Help Anchor
2425
+ // Set Help Anchor if given by help anchor
2407
2426
{
2408
2427
NSString * helpAddress = [error helpAnchor ] ;
2409
2428
if (helpAddress) {
2410
2429
[self setHelpAddress: helpAddress] ;
2411
2430
}
2412
2431
}
2413
-
2432
+
2433
+ // Set Help Anchor if given by help URL (may override helpAnchor)
2434
+ {
2435
+ NSURL * helpUrl = [[error userInfo ] objectForKey: SSYHelpUrlErrorKey] ;
2436
+ if (helpUrl) {
2437
+ [self setHelpAddress: helpUrl.absoluteString] ;
2438
+ }
2439
+ }
2440
+
2414
2441
// Set smallText
2415
2442
[self setSmallText: [error localizedDeepDescription ]] ;
2416
2443
0 commit comments