NSAlert runModal black window


Marco S Hyman
 

Has NSAlert changed recently? Looking at the documentation I see that the only initializer (swift) is `init(error: Error)` yet my code never passes an error. Is the Error argument new?

But my issue is this:

// put up an alert
let alert = NSAlert()
alert.alertStyle = NSAlert.Style.informational
alert.addButton(withTitle: NSLocalizedString("CLOSE", comment: "Close"))
alert.messageText = NSLocalizedString("GPX_LOADED_TITLE", comment: "GPX file loaded")
alert.informativeText = url.path
alert.informativeText += NSLocalizedString("GPX_LOADED_DESC", comment: "GPX file loaded")
alert.runModal()

Sometimes it works. Other times I get a black window with only the app icon and the close button showing. This is a new issue, first noted while testing with Xcode 10.0 running on Mojave. I am not using the dark appearance.

Marc


Chris Hanson
 

On Oct 28, 2018, at 4:20 PM, Marco S Hyman <marc@...> wrote:

Sometimes it works. Other times I get a black window with only the app icon and the close button showing. This is a new issue, first noted while testing with Xcode 10.0 running on Mojave. I am not using the dark appearance.
My first assumption with symptoms like this is that there’s something trying to do UI from a background thread.

-- Chris


Marco S Hyman
 

On Oct 29, 2018, at 12:04 AM, Chris Hanson <cmhanson@...> wrote:

On Oct 28, 2018, at 4:20 PM, Marco S Hyman <marc@...> wrote:

Sometimes it works. Other times I get a black window with only the app icon and the close button showing. This is a new issue, first noted while testing with Xcode 10.0 running on Mojave. I am not using the dark appearance.
My first assumption with symptoms like this is that there’s something trying to do UI from a background thread.
Good thought, but I don’t think that is the problem this time. The alert is created in a function diretly called called from

func tableView(_ tableView: NSTableView,
acceptDrop info: NSDraggingInfo,
row: Int,
dropOperation: NSTableView.DropOperation) -> Bool {
...
}

which is invoked when a file of the appropriate type is dragged and dropped onto a table view. I’m not aware of any threading issues with drag and drop.

It does seem to be some kind of timing issue, though. I can not reproduce it with 100% reliability. Example, setting a breakpoint at the call to alert.runModal() will usually make things work.

Marc