From f94e51e6baac02a702f7f1d38732f9d610ccf7fa Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Thu, 25 Feb 2021 09:52:33 -0500 Subject: [PATCH] windows race condition --- simpledisplay.d | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/simpledisplay.d b/simpledisplay.d index e5f9f57..5a9e359 100644 --- a/simpledisplay.d +++ b/simpledisplay.d @@ -1745,6 +1745,7 @@ class SimpleWindow : CapableOfHandlingNativeEvent, CapableOfBeingDrawnUpon { void close() { if (!_closed) { runInGuiThread( { + if(_closed) return; // another thread got to it first. this is a big FIXME like this is all pretty wtf-y if (onClosing !is null) onClosing(); impl.closeWindow(); _closed = true; @@ -8371,13 +8372,11 @@ bool runInGuiThread(scope void delegate() dg) @trusted { if(!SimpleWindow.eventWakeUp()) throw new Error("runInGuiThread impossible; eventWakeUp failed"); - if(guiThreadTerminating) - return false; - rqm.signal.wait(); + auto t = rqm.thrown; - if(rqm.thrown) - throw rqm.thrown; + if(t) + throw t; return true; }