Panic if the user attempts to create window on non-main thread

This commit is contained in:
mitchmindtree 2017-02-05 19:47:39 +11:00
parent b62ecfd517
commit 926e03039f

View file

@ -197,6 +197,10 @@ impl Window {
pl_attribs: &PlatformSpecificWindowBuilderAttributes)
-> Result<Window, CreationError>
{
if !msg_send![cocoa::base::class("NSThread"), isMainThread] {
panic!("Windows can only be created on the main thread on macOS");
}
let app = match Window::create_app(pl_attribs.activation_policy) {
Some(app) => app,
None => { return Err(OsError(format!("Couldn't create NSApplication"))); },