Closed Bug 1726833 Opened 4 years ago Closed 4 years ago

Calling -[NSAlert runModal] before ProcessPendingGetURLAppleEvents causes invisible windows

Categories

(Core :: Widget: Cocoa, defect, P3)

All
macOS
defect

Tracking

()

RESOLVED WORKSFORME

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];

Severity: -- → S3
Priority: -- → P3

Quite likely it doesn't help, but I noticed this code somewhere else which may be worth trying:

	if (![NSApp isActive]) {
		[NSApp activateIgnoringOtherApps:YES];
	}

After reworking patch 4 in bug 516362, this is no longer an issue.

Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.