From: Jean-Philippe Bruyère Date: Mon, 11 Jan 2021 23:36:12 +0000 (+0100) Subject: ConditionalAttribute for debuglog.addevent, perfTest debug and improvments X-Git-Tag: v0.9.5-beta~107 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=0c65d2b5a26986ad51306617c8fbd4f7bcc81d50;p=jp%2Fcrow.git ConditionalAttribute for debuglog.addevent, perfTest debug and improvments --- diff --git a/Crow/Icons/exit.svg b/Crow/Icons/exit.svg new file mode 100644 index 00000000..cb8d1c27 --- /dev/null +++ b/Crow/Icons/exit.svg @@ -0,0 +1,20 @@ + + + + + diff --git a/Crow/Images/Icons/Cursors/arrow b/Crow/Images/Icons/Cursors/arrow deleted file mode 100644 index 61f968ef..00000000 Binary files a/Crow/Images/Icons/Cursors/arrow and /dev/null differ diff --git a/Crow/Images/Icons/Cursors/bottom_left_corner b/Crow/Images/Icons/Cursors/bottom_left_corner deleted file mode 100644 index e9a41a20..00000000 Binary files a/Crow/Images/Icons/Cursors/bottom_left_corner and /dev/null differ diff --git a/Crow/Images/Icons/Cursors/bottom_right_corner b/Crow/Images/Icons/Cursors/bottom_right_corner deleted file mode 100644 index 208faf48..00000000 Binary files a/Crow/Images/Icons/Cursors/bottom_right_corner and /dev/null differ diff --git a/Crow/Images/Icons/Cursors/cross b/Crow/Images/Icons/Cursors/cross deleted file mode 100644 index 4596b480..00000000 Binary files a/Crow/Images/Icons/Cursors/cross and /dev/null differ diff --git a/Crow/Images/Icons/Cursors/hand b/Crow/Images/Icons/Cursors/hand deleted file mode 100644 index 23939b74..00000000 Binary files a/Crow/Images/Icons/Cursors/hand and /dev/null differ diff --git a/Crow/Images/Icons/Cursors/help b/Crow/Images/Icons/Cursors/help deleted file mode 100644 index cd7ec277..00000000 Binary files a/Crow/Images/Icons/Cursors/help and /dev/null differ diff --git a/Crow/Images/Icons/Cursors/ibeam b/Crow/Images/Icons/Cursors/ibeam deleted file mode 100644 index ccbdcb5c..00000000 Binary files a/Crow/Images/Icons/Cursors/ibeam and /dev/null differ diff --git a/Crow/Images/Icons/Cursors/move b/Crow/Images/Icons/Cursors/move deleted file mode 100644 index ab98f6a3..00000000 Binary files a/Crow/Images/Icons/Cursors/move and /dev/null differ diff --git a/Crow/Images/Icons/Cursors/sb_h_double_arrow b/Crow/Images/Icons/Cursors/sb_h_double_arrow deleted file mode 100644 index 1768b6a0..00000000 Binary files a/Crow/Images/Icons/Cursors/sb_h_double_arrow and /dev/null differ diff --git a/Crow/Images/Icons/Cursors/sb_v_double_arrow b/Crow/Images/Icons/Cursors/sb_v_double_arrow deleted file mode 100644 index a36abd4b..00000000 Binary files a/Crow/Images/Icons/Cursors/sb_v_double_arrow and /dev/null differ diff --git a/Crow/Images/Icons/Cursors/top_left_corner b/Crow/Images/Icons/Cursors/top_left_corner deleted file mode 100644 index 3493adc6..00000000 Binary files a/Crow/Images/Icons/Cursors/top_left_corner and /dev/null differ diff --git a/Crow/Images/Icons/Cursors/top_right_corner b/Crow/Images/Icons/Cursors/top_right_corner deleted file mode 100644 index 264cc577..00000000 Binary files a/Crow/Images/Icons/Cursors/top_right_corner and /dev/null differ diff --git a/Crow/Images/Icons/buttonB.svg b/Crow/Images/Icons/buttonB.svg deleted file mode 100644 index 56bc8d9c..00000000 --- a/Crow/Images/Icons/buttonB.svg +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Crow/Images/Icons/crow.png b/Crow/Images/Icons/crow.png deleted file mode 100644 index 7b737d04..00000000 Binary files a/Crow/Images/Icons/crow.png and /dev/null differ diff --git a/Crow/Images/Icons/exit.svg b/Crow/Images/Icons/exit.svg deleted file mode 100644 index cb8d1c27..00000000 --- a/Crow/Images/Icons/exit.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - diff --git a/Crow/Images/Icons/file.svg b/Crow/Images/Icons/file.svg deleted file mode 100644 index a31c367e..00000000 --- a/Crow/Images/Icons/file.svg +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Crow/Images/Icons/folder.svg b/Crow/Images/Icons/folder.svg deleted file mode 100644 index beac8a1b..00000000 --- a/Crow/Images/Icons/folder.svg +++ /dev/null @@ -1,88 +0,0 @@ - - - -]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Crow/Images/Icons/member.svg b/Crow/Images/Icons/member.svg deleted file mode 100644 index af654a94..00000000 --- a/Crow/Images/Icons/member.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - # - - - - - - - - - - - - diff --git a/Crow/Images/Icons/tetra.png b/Crow/Images/Icons/tetra.png deleted file mode 100644 index b0c855aa..00000000 Binary files a/Crow/Images/Icons/tetra.png and /dev/null differ diff --git a/Crow/Images/crow.png b/Crow/Images/crow.png new file mode 100644 index 00000000..7b737d04 Binary files /dev/null and b/Crow/Images/crow.png differ diff --git a/Crow/Images/screenshot.png b/Crow/Images/screenshot.png deleted file mode 100644 index 3540d6b1..00000000 Binary files a/Crow/Images/screenshot.png and /dev/null differ diff --git a/Crow/Images/screenshot2.png b/Crow/Images/screenshot2.png deleted file mode 100644 index 46a7bec2..00000000 Binary files a/Crow/Images/screenshot2.png and /dev/null differ diff --git a/Crow/src/DebugUtils/DbgEvent.cs b/Crow/src/DebugUtils/DbgEvent.cs index 00c0d9e7..a4bdd058 100644 --- a/Crow/src/DebugUtils/DbgEvent.cs +++ b/Crow/src/DebugUtils/DbgEvent.cs @@ -180,12 +180,12 @@ namespace Crow } public override bool IsWidgetEvent => true; public DbgWidgetEvent () { } -#if DEBUG_LOG public DbgWidgetEvent (long timeStamp, DbgEvtType evt, Widget w) : base (timeStamp, evt) { +#if DEBUG_LOG InstanceIndex = w.instanceIndex; - } #endif + } public override string ToString () => $"{base.ToString ()};{InstanceIndex}"; } @@ -230,6 +230,10 @@ namespace Crow OldSlot = lqi.Slot; NewSlot = lqi.NewSlot; } +#else + public DbgLayoutEvent (long timeStamp, DbgEvtType evt, LayoutingQueueItem lqi) {} + public void SetLQI (LayoutingQueueItem lqi) { } + #endif public override string ToString () => $"{base.ToString ()};{layouting};{result};{OldSlot};{NewSlot}"; diff --git a/Crow/src/DebugUtils/DbgEventWidget (copie).cs b/Crow/src/DebugUtils/DbgEventWidget (copie).cs index c7892a9b..f6b4dc6b 100644 --- a/Crow/src/DebugUtils/DbgEventWidget (copie).cs +++ b/Crow/src/DebugUtils/DbgEventWidget (copie).cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using Crow.Cairo; -#if DEBUG_LOG + namespace Crow { /* @@ -84,4 +84,3 @@ namespace Crow } }*/ } -#endif \ No newline at end of file diff --git a/Crow/src/DebugUtils/DebugLogger.cs b/Crow/src/DebugUtils/DebugLogger.cs index 65e49d53..0c3f38dc 100644 --- a/Crow/src/DebugUtils/DebugLogger.cs +++ b/Crow/src/DebugUtils/DebugLogger.cs @@ -79,7 +79,7 @@ namespace Crow All = 0x0FFFFFFF } -#if DEBUG_LOG + public static class DbgLogger { public static DbgEvtType IncludeEvents = DbgEvtType.All; @@ -109,24 +109,26 @@ namespace Crow } } - public static DbgEvent StartEvent (DbgEvtType evtType, params object[] data) + [Conditional ("DEBUG_LOG")] + public static void StartEvent (DbgEvtType evtType, params object[] data) { if (!logevt (evtType)) - return null; + return; lock (logMutex) { chrono.Stop (); DbgEvent evt = addEventInternal (evtType, data); if (!startedEvents.ContainsKey (Thread.CurrentThread.ManagedThreadId)) startedEvents [Thread.CurrentThread.ManagedThreadId] = new Stack (); startedEvents [Thread.CurrentThread.ManagedThreadId].Push (evt); - chrono.Start (); - return evt; + chrono.Start (); } } - public static DbgEvent EndEvent (DbgEvtType evtType, bool discardIfNoChildEvents = false) + + [Conditional ("DEBUG_LOG")] + public static void EndEvent (DbgEvtType evtType, bool discardIfNoChildEvents = false) { if (!logevt (evtType)) - return null; + return; lock (logMutex) { chrono.Stop (); @@ -140,16 +142,36 @@ namespace Crow else e.end = chrono.ElapsedTicks; chrono.Start (); - return e; } } + + // End layouting queue event and set the corresponding lqi + [Conditional ("DEBUG_LOG")] + public static void EndEvent (DbgEvtType evtType, LayoutingQueueItem lqi) { + if (!logevt (evtType)) + return; + + lock (logMutex) { + chrono.Stop (); + if (!startedEvents.ContainsKey (Thread.CurrentThread.ManagedThreadId)) + throw new Exception ("Current thread has no event started"); + DbgLayoutEvent e = startedEvents[Thread.CurrentThread.ManagedThreadId].Pop () as DbgLayoutEvent; + if (e?.type != evtType) + throw new Exception ($"Begin/end event logging mismatch: {e.type}/{evtType}"); + e.end = chrono.ElapsedTicks; + e.SetLQI (lqi); + chrono.Start (); + } + + } /// /// End event by reference to cancel unended events on failure /// - public static DbgEvent EndEvent (DbgEvtType evtType, DbgEvent evt) + /* + public static void EndEvent (DbgEvtType evtType, DbgEvent evt) { if (!logevt (evtType)) - return null; + return; lock (logMutex) { chrono.Stop (); @@ -162,17 +184,17 @@ namespace Crow chrono.Start (); return e; } - } + }*/ - public static DbgEvent AddEvent (DbgEvtType evtType, params object [] data) { + [Conditional("DEBUG_LOG")] + public static void AddEvent (DbgEvtType evtType, params object [] data) { if (!logevt (evtType)) - return null; + return; lock (logMutex) { chrono.Stop (); DbgEvent evt = addEventInternal (evtType, data); chrono.Start (); - return evt; } } @@ -191,7 +213,7 @@ namespace Crow curEventList.Add (evt); return evt; } - +#if DEBUG_LOG static void parseTree (Widget go, int level = 0, int y = 1) { if (go == null) return; @@ -256,9 +278,8 @@ namespace Crow saveEventList (s, e.Events, level + 1); } } - - } #endif + } } diff --git a/Crow/src/IML/Instantiator.cs b/Crow/src/IML/Instantiator.cs index 32afce34..3df0688f 100644 --- a/Crow/src/IML/Instantiator.cs +++ b/Crow/src/IML/Instantiator.cs @@ -73,14 +73,12 @@ namespace Crow.IML { /// public Instantiator (Interface _iface, Stream stream, string srcPath = null) { - #if DESIGN_MODE +#if DESIGN_MODE currentInstantiatorID = NextInstantiatorID++; - #endif +#endif iface = _iface; sourcePath = srcPath; -#if DEBUG_LOG - DbgEvent de = DbgLogger.StartEvent (DbgEvtType.CreateITor, sourcePath); -#endif + DbgLogger.StartEvent (DbgEvtType.CreateITor, sourcePath); try { using (XmlReader itr = XmlReader.Create (stream)) { parseIML (itr); @@ -89,9 +87,7 @@ namespace Crow.IML { throw new InstantiatorException(sourcePath, ex); } finally { stream?.Dispose (); -#if DEBUG_LOG - DbgLogger.EndEvent (DbgEvtType.CreateITor, de); -#endif + DbgLogger.EndEvent (DbgEvtType.CreateITor); } } /// diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index 2f5f664d..62380aaf 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -231,16 +231,12 @@ namespace Crow /// load styling, init default tooltips and context menus, load main.crow resource if exists. /// public void Init () { -#if DEBUG_LOG DbgLogger.StartEvent (DbgEvtType.IFaceInit); -#endif loadStyling (); initTooltip (); initContextMenus (); OnInitialized (); -#if DEBUG_LOG DbgLogger.EndEvent (DbgEvtType.IFaceInit); -#endif } /// /// call Init() then enter the running loop performing ProcessEvents until running==false. @@ -570,14 +566,12 @@ namespace Crow public Widget Load (string path) { lock (UpdateMutex) { - #if DEBUG_LOG DbgLogger.StartEvent (DbgEvtType.IFaceLoad); - #endif + Widget tmp = CreateInstance (path); AddWidget (tmp); - #if DEBUG_LOG + DbgLogger.EndEvent (DbgEvtType.IFaceLoad); - #endif return tmp; } } @@ -630,9 +624,7 @@ namespace Crow _activeWidget = value; NotifyValueChanged ("ActiveWidget", _activeWidget); -#if DEBUG_LOG DbgLogger.AddEvent (DbgEvtType.ActiveWidget, _activeWidget); -#endif if (_activeWidget != null) _activeWidget.IsActive = true; @@ -652,9 +644,7 @@ namespace Crow _hoverWidget = value; NotifyValueChanged ("HoverWidget", _hoverWidget); -#if DEBUG_LOG DbgLogger.AddEvent (DbgEvtType.HoverWidget, _hoverWidget); -#endif if (DragAndDropOperation == null && FOCUS_ON_HOVER) { Widget w = _hoverWidget; @@ -682,9 +672,7 @@ namespace Crow _focusedWidget = value; NotifyValueChanged ("FocusedWidget", _focusedWidget); -#if DEBUG_LOG DbgLogger.AddEvent (DbgEvtType.FocusedWidget, _focusedWidget); -#endif if (_focusedWidget != null) _focusedWidget.HasFocus = true; } @@ -701,14 +689,9 @@ namespace Crow lock (ClippingMutex) { if (g.IsQueueForClipping) return; -#if DEBUG_LOG - DbgLogger.StartEvent (DbgEvtType.GOEnqueueForRepaint, g); -#endif + DbgLogger.AddEvent (DbgEvtType.GOEnqueueForRepaint, g); ClippingQueue.Enqueue (g); g.IsQueueForClipping = true; -#if DEBUG_LOG - DbgLogger.EndEvent (DbgEvtType.GOEnqueueForRepaint); -#endif } } /// Main Update loop, executed in this interface thread, protected by the UpdateMutex @@ -741,9 +724,7 @@ namespace Crow if (!Monitor.TryEnter (UpdateMutex)) return; -#if DEBUG_LOG DbgLogger.StartEvent (DbgEvtType.Update); -#endif processLayouting (); @@ -755,9 +736,7 @@ namespace Crow }else processDrawing (ctx); -#if DEBUG_LOG DbgLogger.EndEvent (DbgEvtType.Update, true); -#endif Monitor.Exit (UpdateMutex); } @@ -766,9 +745,9 @@ namespace Crow /// trigger an enqueue for the next Update Cycle protected virtual void processLayouting(){ if (Monitor.TryEnter (LayoutMutex)) { -#if DEBUG_LOG + DbgLogger.StartEvent (DbgEvtType.Layouting); -#endif + DiscardQueue = new Queue (); //Debug.WriteLine ("======= Layouting queue start ======="); LayoutingQueueItem lqi; @@ -777,9 +756,9 @@ namespace Crow lqi.ProcessLayouting (); } LayoutingQueue = DiscardQueue; -#if DEBUG_LOG + DbgLogger.EndEvent (DbgEvtType.Layouting, true); -#endif + Monitor.Exit (LayoutMutex); DiscardQueue = null; } @@ -788,9 +767,9 @@ namespace Crow /// Clipping rectangles are added at each level of the tree from leef to root, that's the way for the painting /// operation to known if it should go down in the tree for further graphic updates and repaints void clippingRegistration(){ -#if DEBUG_LOG + DbgLogger.StartEvent (DbgEvtType.Clipping); -#endif + Widget g = null; while (ClippingQueue.Count > 0) { lock (ClippingMutex) { @@ -799,16 +778,15 @@ namespace Crow } g.ClippingRegistration (); } -#if DEBUG_LOG + DbgLogger.EndEvent (DbgEvtType.Clipping, true); -#endif } /// Clipping Rectangles drive the drawing process. For compositing, each object under a clip rectangle should be /// repainted. If it contains also clip rectangles, its cache will be update, or if not cached a full redraw will take place void processDrawing(Context ctx){ -#if DEBUG_LOG + DbgLogger.StartEvent (DbgEvtType.Drawing); -#endif + if (DragImage != null) clipping.UnionRectangle(new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight)); if (!clipping.IsEmpty) { @@ -870,9 +848,7 @@ namespace Crow clipping = new Region (); } -#if DEBUG_LOG DbgLogger.EndEvent (DbgEvtType.Drawing, true); -#endif } #endregion diff --git a/Crow/src/LayoutingQueueItem.cs b/Crow/src/LayoutingQueueItem.cs index 86d3e9e7..c6aa6dc6 100644 --- a/Crow/src/LayoutingQueueItem.cs +++ b/Crow/src/LayoutingQueueItem.cs @@ -3,13 +3,10 @@ // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; -using System.Diagnostics; -using System.Collections.Generic; -using System.Linq; namespace Crow { - [Flags] + [Flags] public enum LayoutingType : byte { None = 0x00, @@ -62,7 +59,7 @@ namespace Crow get { return graphicObject.Height; } } public Rectangle Slot, NewSlot; - #endif +#endif #region CTOR public LayoutingQueueItem (LayoutingType _layoutType, ILayoutable _graphicObject) @@ -72,12 +69,12 @@ namespace Crow Layoutable.RegisteredLayoutings |= LayoutType; LayoutingTries = 0; DiscardCount = 0; - #if DEBUG_LOG +#if DEBUG_LOG Slot = Rectangle.Zero; NewSlot = Rectangle.Zero; result = Result.Register; DbgLogger.AddEvent (DbgEvtType.GORegisterLayouting, this); - #endif +#endif } #endregion @@ -95,57 +92,49 @@ namespace Crow if (go.Parent == null) {//TODO:improve this //cancel layouting for object without parent, maybe some were in queue when //removed from a listbox - #if DEBUG_LOG DbgLogger.AddEvent (DbgEvtType.GOProcessLayoutingWithNoParent, this); - #endif go.parentRWLock.ExitReadLock (); return; } - #if DEBUG_LOG +#if DEBUG_LOG DbgLogger.StartEvent (DbgEvtType.GOProcessLayouting, this); Slot = graphicObject.Slot; - #endif +#endif LayoutingTries++; if (!Layoutable.UpdateLayout (LayoutType)) { if (LayoutingTries < Interface.MaxLayoutingTries) { Layoutable.RegisteredLayoutings |= LayoutType; (Layoutable as Widget).IFace.LayoutingQueue.Enqueue (this); - #if DEBUG_LOG +#if DEBUG_LOG result = Result.Requeued; - #endif +#endif } else if (DiscardCount < Interface.MaxDiscardCount) { - #if DEBUG_LOG +#if DEBUG_LOG result = Result.Discarded; - #endif +#endif LayoutingTries = 0; DiscardCount++; Layoutable.RegisteredLayoutings |= LayoutType; (Layoutable as Widget).IFace.DiscardQueue.Enqueue (this); } - #if DEBUG_LOG +#if DEBUG_LOG else { result = Result.Deleted; } - #endif +#endif } - #if DEBUG_LOG +#if DEBUG_LOG else{ result = Result.Success; } NewSlot = graphicObject.Slot; - (DbgLogger.EndEvent (DbgEvtType.GOProcessLayouting) as DbgLayoutEvent).SetLQI (this); - #endif + DbgLogger.EndEvent (DbgEvtType.GOProcessLayouting, this); +#endif go.parentRWLock.ExitReadLock (); } - public static implicit operator Widget(LayoutingQueueItem queueItem) - { - return queueItem.Layoutable as Widget; - } - public static implicit operator LayoutingType(LayoutingQueueItem lqi) - { - return lqi.LayoutType; - } + public static implicit operator Widget(LayoutingQueueItem queueItem) => queueItem.Layoutable as Widget; + public static implicit operator LayoutingType(LayoutingQueueItem lqi) => lqi.LayoutType; public override string ToString () => $"{LayoutType};{Layoutable.ToString ()};{LayoutingTries};{DiscardCount}"; } diff --git a/Crow/src/Widgets/Button.cs b/Crow/src/Widgets/Button.cs index 58a35032..ce514ce0 100644 --- a/Crow/src/Widgets/Button.cs +++ b/Crow/src/Widgets/Button.cs @@ -62,7 +62,7 @@ namespace Crow } } - [DefaultValue ("#Crow.Images.button.svg")] + [DefaultValue ("#Crow.Icons.crow.svg")] public string Icon { get { return Command == null ? icon : Command.Icon; ; } set { diff --git a/Crow/src/Widgets/Group.cs b/Crow/src/Widgets/Group.cs index 5f0a7b21..b2b438cd 100644 --- a/Crow/src/Widgets/Group.cs +++ b/Crow/src/Widgets/Group.cs @@ -67,12 +67,10 @@ namespace Crow set { _multiSelect = value; } } public virtual void AddChild(Widget g){ -#if DEBUG_LOG if (disposed) { DbgLogger.AddEvent (DbgEvtType.AlreadyDisposed | DbgEvtType.GOAddChild); return; } -#endif childrenRWLock.EnterWriteLock(); @@ -116,12 +114,10 @@ namespace Crow child.Dispose (); } public virtual void InsertChild (int idx, Widget g) { -#if DEBUG_LOG if (disposed) { DbgLogger.AddEvent (DbgEvtType.AlreadyDisposed | DbgEvtType.GOAddChild); return; } -#endif childrenRWLock.EnterWriteLock (); g.Parent = this; @@ -395,9 +391,8 @@ namespace Crow } void searchLargestChild (bool forceMeasure = false) { -#if DEBUG_LOG DbgLogger.StartEvent (DbgEvtType.GOSearchLargestChild, this); -#endif + largestChild = null; contentSize.Width = 0; for (int i = 0; i < Children.Count; i++) { @@ -415,15 +410,13 @@ namespace Crow largestChild = Children [i]; } } -#if DEBUG_LOG + DbgLogger.EndEvent (DbgEvtType.GOSearchLargestChild); -#endif } void searchTallestChild (bool forceMeasure = false) { -#if DEBUG_LOG DbgLogger.StartEvent (DbgEvtType.GOSearchTallestChild, this); -#endif + tallestChild = null; contentSize.Height = 0; for (int i = 0; i < Children.Count; i++) { @@ -441,9 +434,7 @@ namespace Crow tallestChild = Children [i]; } } -#if DEBUG_LOG DbgLogger.EndEvent (DbgEvtType.GOSearchTallestChild); -#endif } diff --git a/Crow/src/Widgets/TemplatedGroup.cs b/Crow/src/Widgets/TemplatedGroup.cs index f4e63f43..36b117eb 100644 --- a/Crow/src/Widgets/TemplatedGroup.cs +++ b/Crow/src/Widgets/TemplatedGroup.cs @@ -296,9 +296,8 @@ namespace Crow { /// Items loading thread /// void loading(){ -#if DEBUG_LOG DbgLogger.StartEvent (DbgEvtType.TGLoadingThread, this); -#endif + try { loadPage (data, items, dataTest); } catch (Exception ex) { @@ -306,9 +305,8 @@ namespace Crow { Monitor.Exit (IFace.LayoutMutex); System.Diagnostics.Debug.WriteLine ("loading thread aborted: " + ex.ToString()); } -#if DEBUG_LOG + DbgLogger.EndEvent (DbgEvtType.TGLoadingThread); -#endif } // //if (!ItemTemplates.ContainsKey ("default")) // // ItemTemplates ["default"] = Interface.GetItemTemplate (ItemTemplate); @@ -328,9 +326,7 @@ namespace Crow { bool updateMx = Monitor.IsEntered (IFace.UpdateMutex); bool layoutMx = Monitor.IsEntered (IFace.LayoutMutex); -#if DEBUG_LOG DbgLogger.AddEvent (DbgEvtType.TGCancelLoadingThread, this); -#endif if (layoutMx) Monitor.Exit (IFace.LayoutMutex); diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index 4a99e2da..23329c76 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -147,36 +147,29 @@ namespace Crow } protected virtual void Dispose(bool disposing){ if (disposed){ -#if DEBUG_LOG DbgLogger.AddEvent (DbgEvtType.AlreadyDisposed, this); -#endif return; } - -#if DEBUG_LOG DbgLogger.StartEvent (DbgEvtType.Disposing, this); -#endif - if (disposing) { + if (disposing) { unshownPostActions (); if (!localDataSourceIsNull) DataSource = null; - parentRWLock.EnterWriteLock(); + parentRWLock.EnterWriteLock (); parent = null; - parentRWLock.ExitWriteLock(); - } -#if DEBUG_LOG - else + parentRWLock.ExitWriteLock (); + } else { DbgLogger.AddEvent (DbgEvtType.DisposedByGC, this); -#endif + } + Clipping?.Dispose (); bmp?.Dispose (); disposed = true; -#if DEBUG_LOG + DbgLogger.EndEvent (DbgEvtType.Disposing); -#endif } #endregion @@ -992,16 +985,14 @@ namespace Crow if (value != null) rootDataLevel = true; - #if DEBUG_LOG DbgLogger.StartEvent(DbgEvtType.GOLockUpdate, this); - #endif + lock (IFace.UpdateMutex) { OnDataSourceChanged (this, dse); NotifyValueChangedAuto (DataSource); } - #if DEBUG_LOG + DbgLogger.EndEvent (DbgEvtType.GOLockUpdate); - #endif } get { return rootDataLevel ? dataSource : dataSource == null ? @@ -1093,9 +1084,7 @@ namespace Crow /// Loads the default values from XML attributes default public void loadDefaultValues() { - #if DEBUG_LOG DbgLogger.StartEvent (DbgEvtType.GOInitialization, this); - #endif Type thisType = this.GetType (); @@ -1272,9 +1261,7 @@ namespace Crow protected virtual void onInitialized (object sender, EventArgs e){ Initialized.Raise(sender, e); - #if DEBUG_LOG DbgLogger.EndEvent (DbgEvtType.GOInitialization); - #endif } bool getDefaultEvent(EventInfo ei, List