From: Jean-Philippe Bruyère Date: Sat, 27 Mar 2021 18:48:03 +0000 (+0100) Subject: test loadingThread != null before checking cancel state X-Git-Tag: v0.9.5-beta~40 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=4c6ffee1ea8206568de42b2d4e7b82883a984b7e;p=jp%2Fcrow.git test loadingThread != null before checking cancel state --- diff --git a/Crow/src/Widgets/TemplatedGroup.cs b/Crow/src/Widgets/TemplatedGroup.cs index 7c84f545..cfa6cd1c 100644 --- a/Crow/src/Widgets/TemplatedGroup.cs +++ b/Crow/src/Widgets/TemplatedGroup.cs @@ -440,10 +440,14 @@ namespace Crow { if (iTemp == null) iTemp = ItemTemplates ["default"]; } - while (!Monitor.TryEnter(IFace.LayoutMutex)) { - if (loadingThread.cancelRequested) - return; - Thread.Sleep(1); + if (loadingThread == null) + Monitor.Enter(IFace.LayoutMutex); + else { + while (!Monitor.TryEnter(IFace.LayoutMutex)) { + if (loadingThread.cancelRequested) + return; + Thread.Sleep(1); + } } g = iTemp.CreateInstance();