From 926e03039f4a596eac717ff598eaf8a5ac093aa8 Mon Sep 17 00:00:00 2001 From: mitchmindtree Date: Sun, 5 Feb 2017 19:47:39 +1100 Subject: [PATCH] Panic if the user attempts to create window on non-main thread --- src/platform/macos/window.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/platform/macos/window.rs b/src/platform/macos/window.rs index d9959fb9..ccc178eb 100644 --- a/src/platform/macos/window.rs +++ b/src/platform/macos/window.rs @@ -197,6 +197,10 @@ impl Window { pl_attribs: &PlatformSpecificWindowBuilderAttributes) -> Result { + 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"))); },