]> O.S.I.I.S - jp/crow.git/commitdiff
remove threading for ListBox, not functionnal
authorjpbruyere <jp.bruyere@hotmail.com>
Thu, 4 Feb 2016 18:35:36 +0000 (19:35 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Thu, 4 Feb 2016 18:35:36 +0000 (19:35 +0100)
src/GraphicObjects/ListBox.cs
src/Interface.cs
src/OpenTKGameWindow.cs

index a0ab540e2e150cc045e7643a5680fecb715f586e..788d835f8ea58f96163288528dac95b4eb6df2c1 100644 (file)
@@ -75,98 +75,46 @@ namespace Crow
                        get {
                                return data;
                        }
-                       set {                   
-                               if (loadingInProgress) {                                        
-                                       thread.Join ();
-                                       Interface.LoadingLists.Remove (this);
-                                       pendingChildrenAddition = null;
-                                       loadingInProgress = false;
-                               }
-
+                       set {
+                               
                                data = value;
 
                                _list.ClearChildren ();
 
                                if (data == null)
                                        return;
-
-                               pendingChildrenAddition = new Queue<GraphicObject> ();
-                               threadedLoadingFinished = false;
-                               Interface.LoadingLists.Add (this);
-
-                               thread = new Thread(loadingThread);
-                               loadingInProgress = true;
-                               thread.IsBackground = true;
-                               thread.Start ();
-                               thread.Join ();
-                       }
-               }
-//             public override void UpdateLayout (LayoutingType layoutType)
-//             {
-//                     CheckPendingChildrenAddition ();
-//                     base.UpdateLayout (layoutType);
-//             }
-               internal void CheckPendingChildrenAddition()
-               {
-                       if (!loadingInProgress)
-                               return;
-                       lock (pendingChildrenAddition) {
-                               if (!threadedLoadingFinished && pendingChildrenAddition.Count < 10)
-                                       return;
-                               while (pendingChildrenAddition.Count > 0) {
-                                       GraphicObject tmp = pendingChildrenAddition.Dequeue ();
-                                       tmp.DataSource = tmp.Tag;
-                                       tmp.Tag = null;
-                                       _list.addChild (tmp);
-                               }
-                               if (threadedLoadingFinished) {
-                                       Interface.LoadingLists.Remove (this);
-                                       pendingChildrenAddition = null;
-                                       loadingInProgress = false;
+                               
+                               #if DEBUG_LOAD_TIME
+                               Stopwatch loadingTime = new Stopwatch ();
+                               loadingTime.Start ();
+                               #endif
+
+                               MemoryStream ms = new MemoryStream ();
+                               lock (ItemTemplate) {
+                                       using (Stream stream = Interface.GetStreamFromPath (ItemTemplate))
+                                               stream.CopyTo (ms);
                                }
-                       }
-               }
-
-               Queue<GraphicObject> pendingChildrenAddition;
-               volatile bool threadedLoadingFinished = false;
-               volatile bool loadingInProgress = false;
-               Thread thread;
-
-               void loadingThread()
-               {
-                       #if DEBUG_LOAD_TIME
-                       Stopwatch loadingTime = new Stopwatch ();
-                       loadingTime.Start ();
-                       #endif
-
-                       MemoryStream ms = new MemoryStream ();
-                       lock (ItemTemplate) {
-                               using (Stream stream = Interface.GetStreamFromPath (ItemTemplate))
-                                       stream.CopyTo (ms);
-                       }
 
-                       Type t = Interface.GetTopContainerOfGOMLStream (ms);
+                               Type t = Interface.GetTopContainerOfGOMLStream (ms);
 
-                       foreach (var item in data) {
-                               ms.Seek(0,SeekOrigin.Begin);
-                               GraphicObject g = Interface.Load (ms, t);
-                               g.Tag = item;
-                               g.MouseClick += itemClick;
-                               lock (pendingChildrenAddition) {
-                                       pendingChildrenAddition.Enqueue (g);
+                               foreach (var item in data) {
+                                       ms.Seek(0,SeekOrigin.Begin);
+                                       GraphicObject g = Interface.Load (ms, t);
+                                       g.DataSource = item;
+                                       g.MouseClick += itemClick;
+                                       _list.addChild (g);
                                }
-                       }
-
-                       ms.Dispose ();                  
 
-                       threadedLoadingFinished = true;
+                               ms.Dispose ();                  
 
-                       #if DEBUG_LOAD_TIME
-                       loadingTime.Stop ();
-                       Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",
+                               #if DEBUG_LOAD_TIME
+                               loadingTime.Stop ();
+                               Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",
                                loadingTime.ElapsedTicks,
                                loadingTime.ElapsedMilliseconds, this.ToString());
-                       #endif
+                               #endif
+
+                       }
                }
 
                void itemClick(object sender, OpenTK.Input.MouseButtonEventArgs e){
index 6d4d259bb9d7a4fb8704723a999e4b895c65664c..e6be4220121c8c8294385c9df6a06f3ef4c21cfb 100644 (file)
@@ -53,7 +53,6 @@ namespace Crow
                /// <summary> Threshold to catch borders for sizing </summary>
                public static int BorderThreshold = 5;
 
-               public static List<ListBox> LoadingLists= new List<ListBox>();
                public static LayoutingQueue LayoutingQueue = new LayoutingQueue ();
 
                #region Load/Save
index 587dd9683fbd75cf16d647e14d2e958443dc847a..81bb0258046be2e0f75570f836dac01ffd9b1d64 100644 (file)
@@ -249,13 +249,6 @@ namespace Crow
                        surf = new ImageSurface(bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height,ClientRectangle.Width*4);
                        ctx = new Context(surf);
 
-                       if (Interface.LoadingLists.Count > 0) {
-                               ListBox[] loadings = new ListBox[Interface.LoadingLists.Count];
-                               Interface.LoadingLists.CopyTo (loadings, 0);
-                               for (int i = 0; i < loadings.Length; i++)
-                                       loadings [i].CheckPendingChildrenAddition ();                           
-                       }
-
                        GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count];
                        GraphicObjects.CopyTo (invGOList,0);
                        invGOList = invGOList.Reverse ().ToArray ();