Calling -[NSAlert runModal] before ProcessPendingGetURLAppleEvents causes invisible windows
Categories
(Core :: Widget: Cocoa, defect, P3)
Tracking
()
People
(Reporter: mstange, Assigned: mstange)
References
Details
This problem came up in bug 516362, which is showing an NSAlert early during startup (when Firefox is launched from a dmg). When that alert is dismissed, the initial Firefox window is invisible. The app is active, and the main menu works correctly, the window just isn't shown. It only appears once the Dock icon is clicked.
This can be reproduced by inserting the following code anywhere before the call to ProcessPendingGetURLAppleEvents():
NSAlert* alert = [[[NSAlert alloc] init] autorelease];
[alert setAlertStyle:NSAlertStyleInformational];
[alert setMessageText:@"Message"];
[alert setInformativeText:@"Text"];
[alert addButtonWithTitle:@"Button"];
[alert addButtonWithTitle:@"Button"];
[alert runModal];
It seems that this can be worked around by initializing the NSApp event loop before opening the NSAlert.
For example, this piece of code seems to be an effective workaround:
[NSApp nextEventMatchingMask:NSEventMaskAny untilDate:nil inMode:NSDefaultRunLoopMode dequeue:NO];
Updated•4 years ago
|
Comment 1•4 years ago
|
||
Quite likely it doesn't help, but I noticed this code somewhere else which may be worth trying:
if (![NSApp isActive]) {
[NSApp activateIgnoringOtherApps:YES];
}
Comment 2•4 years ago
|
||
After reworking patch 4 in bug 516362, this is no longer an issue.
Description
•