Skip to content

Commit 9f9d3cd

Browse files
committed
-[SSYAlert init] now NSLogs and returns nil if called from a non-main thread.
1 parent 1a49530 commit 9f9d3cd

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

SSYAlert.m

+14-4
Original file line numberDiff line numberDiff line change
@@ -2297,15 +2297,25 @@ - (NSControlStateValue)checkboxState {
22972297
// bottom of the menu bar.
22982298

22992299
- (id)init {
2300+
BOOL ok = YES;
2301+
23002302
/* See Note ActivationPolicy. */
23012303
if (!NSApp || ([NSApp activationPolicy] == NSApplicationActivationPolicyProhibited)) {
2304+
ok = NO;
2305+
}
23022306

2307+
if (![[NSThread currentThread] isMainThread]) {
2308+
NSLog(@"Failing attempt to init SSYAlert on non-main thread");
2309+
ok = NO;
2310+
}
2311+
2312+
if (!ok) {
23032313
#if !__has_feature(objc_arc)
2304-
[super dealloc] ;
2314+
[super dealloc] ;
23052315
#endif
2306-
return nil ;
2307-
}
2308-
2316+
return nil ;
2317+
}
2318+
23092319
// Create window
23102320
NSRect initialRect = NSMakeRect(0, 0, WINDOW_PROTOTYPE_WIDTH, WINDOW_PROTOTYPE_HEIGHT) ;
23112321
// WINDOW_PROTOTYPE_WIDTH is because: If I use NSZeroRect, [window center] places

0 commit comments

Comments
 (0)