]> O.S.I.I.S - jp/crow.git/commitdiff
test loadingThread != null before checking cancel state
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 27 Mar 2021 18:48:03 +0000 (19:48 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 27 Mar 2021 18:48:03 +0000 (19:48 +0100)
Crow/src/Widgets/TemplatedGroup.cs

index 7c84f5459c763b9669a18e09b72a89e065993965..cfa6cd1c8e1bbf37678e035bef8fdcbbbdd6d939 100644 (file)
@@ -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();