From 7118251f83338a195922dc70ae1891e29793b386 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 6 Oct 2015 10:57:56 -0300 Subject: [PATCH] Create NSWindow in main thread/queue on Skia/OSX port We cannot create/handle UI controls outside the main thread. --- src/she/skia/skia_window_osx.mm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/she/skia/skia_window_osx.mm b/src/she/skia/skia_window_osx.mm index 094e6dba7..a98d7f319 100644 --- a/src/she/skia/skia_window_osx.mm +++ b/src/she/skia/skia_window_osx.mm @@ -24,18 +24,26 @@ public: gfx::Size clientSize; gfx::Size restoredSize; + Impl() { + closing = false; + scale = 1; + window = [OSXWindow new]; + [window setCloseDelegate:this]; + } + void notifyClose() override { closing = true; } }; SkiaWindow::SkiaWindow(EventQueue* queue, SkiaDisplay* display) - : m_impl(new SkiaWindow::Impl) + : m_impl(nullptr) { - m_impl->closing = false; - m_impl->scale = 1; - m_impl->window = [OSXWindow new]; - [m_impl->window setCloseDelegate:m_impl]; + dispatch_sync( + dispatch_get_main_queue(), + ^{ + m_impl = new SkiaWindow::Impl; + }); } SkiaWindow::~SkiaWindow()