aboutsummaryrefslogtreecommitdiffstatsci
path: root/Samples/DebugLogAnalyzer
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-06-16 16:00:50 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-06-16 16:00:50 +0200
commit5115f379fc240b1250220910b14d69bb27a32c1e (patch)
tree1818ebcf5f2f5bd2f9730d85391217fcd1038c92 /Samples/DebugLogAnalyzer
parent58e1683bdbe1c169a1ab18b170283f8d171049a7 (diff)
using try/finally to ensure mutexes release
Diffstat (limited to 'Samples/DebugLogAnalyzer')
-rw-r--r--Samples/DebugLogAnalyzer/src/DbgEventWidget.cs38
-rw-r--r--Samples/DebugLogAnalyzer/src/DbgLogViewer.cs2
-rw-r--r--Samples/DebugLogAnalyzer/src/DebugInterface.cs21
-rw-r--r--Samples/DebugLogAnalyzer/src/Program.cs16
-rw-r--r--Samples/DebugLogAnalyzer/ui/DebugLog.crow4
5 files changed, 47 insertions, 34 deletions
diff --git a/Samples/DebugLogAnalyzer/src/DbgEventWidget.cs b/Samples/DebugLogAnalyzer/src/DbgEventWidget.cs
index 6af3f6df..b369d248 100644
--- a/Samples/DebugLogAnalyzer/src/DbgEventWidget.cs
+++ b/Samples/DebugLogAnalyzer/src/DbgEventWidget.cs
@@ -30,12 +30,15 @@ namespace Crow
long ticksPerPixel;
double pixelPerTick;
+ object dataMutex = new object();
+
public DbgEvent Event {
get => evt;
set {
if (evt == value)
return;
- evt = value;
+ lock (dataMutex)
+ evt = value;
updatePixelPerTicks ();
NotifyValueChangedAuto (evt);
RegisterForRedraw ();
@@ -46,6 +49,8 @@ namespace Crow
private set {
if (hoverEvt == value)
return;
+ lock (dataMutex)
+ evt = value;
hoverEvt = value;
NotifyValueChangedAuto (hoverEvt);
}
@@ -83,24 +88,27 @@ namespace Crow
protected override void onDraw (Context gr)
{
- if (Event == null) {
- base.onDraw (gr);
- return;
- }
+ lock (dataMutex) {
+
+ if (Event == null) {
+ base.onDraw (gr);
+ return;
+ }
- gr.LineWidth = 1;
- gr.SetDash (new double [] { 1.0, 3.0 }, 0);
+ gr.LineWidth = 1;
+ gr.SetDash (new double [] { 1.0, 3.0 }, 0);
- Rectangle cb = ClientRectangle;
+ Rectangle cb = ClientRectangle;
- if (Event.Duration == 0) {
- gr.SetSource (Event.Color);
- gr.Rectangle (cb);
- gr.Fill ();
- return;
- }
+ if (Event.Duration == 0) {
+ gr.SetSource (Event.Color);
+ gr.Rectangle (cb);
+ gr.Fill ();
+ return;
+ }
- drawEvent (gr, cb.Height, Event);
+ drawEvent (gr, cb.Height, Event);
+ }
}
void drawEvent (Context ctx, int h, DbgEvent dbge)
{
diff --git a/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs b/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs
index d39cc62a..251090ef 100644
--- a/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs
+++ b/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs
@@ -481,7 +481,7 @@ namespace Crow
if (lastTick >= 0 && hoverTick >= 0)
ScrollX += lastTick - hoverTick;
if (lastLine >= 0 && hoverLine >= 0)
- ScrollY += lastLine - hoverLine;
+ ScrollY += lastLine - hoverLine;
updateMouseLocalPos (e.Position);
} else {
HoverWidget = (hoverLine < 0 || hoverLine >= widgets.Count) ? null : widgets [hoverLine];
diff --git a/Samples/DebugLogAnalyzer/src/DebugInterface.cs b/Samples/DebugLogAnalyzer/src/DebugInterface.cs
index 1653f163..64de2163 100644
--- a/Samples/DebugLogAnalyzer/src/DebugInterface.cs
+++ b/Samples/DebugLogAnalyzer/src/DebugInterface.cs
@@ -43,13 +43,28 @@ namespace Crow
}
catch (System.Exception ex)
{
- while (Monitor.IsEntered(LayoutMutex))
+ while (Monitor.IsEntered(LayoutMutex)) {
+ Console.WriteLine ($"[DebugIFace] trying to exit LayoutMutex on error");
+ Monitor.Exit (LayoutMutex);
+ }
+ while (Monitor.IsEntered(UpdateMutex)) {
+ Console.WriteLine ($"[DebugIFace] trying to exit UpdateMutex on error");
+ Monitor.Exit (UpdateMutex);
+ }
+ while (Monitor.IsEntered(ClippingMutex)) {
+ Console.WriteLine ($"[DebugIFace] trying to exit ClippingMutex on error");
+ Monitor.Exit (ClippingMutex);
+ }
+
+
+ /*while (Monitor.IsEntered(LayoutMutex))
Monitor.Exit (LayoutMutex);
while (Monitor.IsEntered(UpdateMutex))
Monitor.Exit (UpdateMutex);
while (Monitor.IsEntered(ClippingMutex))
- Monitor.Exit (ClippingMutex);
- delSetCurrentException (ex);
+ Monitor.Exit (ClippingMutex);*/
+ delSetCurrentException (ex);
+ Console.WriteLine ($"[DbgIFace] {ex}");
ClearInterface();
Thread.Sleep(1000);
}
diff --git a/Samples/DebugLogAnalyzer/src/Program.cs b/Samples/DebugLogAnalyzer/src/Program.cs
index 8cee874a..13e0234d 100644
--- a/Samples/DebugLogAnalyzer/src/Program.cs
+++ b/Samples/DebugLogAnalyzer/src/Program.cs
@@ -21,8 +21,7 @@ namespace DebugLogAnalyzer
static void Main (string [] args)
{
- DbgLogger.IncludeEvents = DbgEvtType.None;
- DbgLogger.DiscardEvents = DbgEvtType.All;
+ initDebugLog ();
using (Program app = new Program ()) {
CurrentProgramInstance = app;
@@ -195,15 +194,6 @@ namespace DebugLogAnalyzer
}
public List<DbgWidgetEvent> CurWidgetRootEvents => curWidget == null? new List<DbgWidgetEvent>() : curWidget.RootEvents;
- public bool DebugLogToFile {
- get => Configuration.Global.Get<bool> (nameof(DebugLogToFile));
- set {
- if (DbgLogger.ConsoleOutput != value)
- return;
- Configuration.Global.Set (nameof(DebugLogToFile), value);
- NotifyValueChanged(DebugLogToFile);
- }
- }
/*public string DebugLogFilePath {
get => Configuration.Global.Get<string> (nameof (DebugLogFilePath));
set {
@@ -216,8 +206,8 @@ namespace DebugLogAnalyzer
public bool DebugLogOnStartup {
get => Configuration.Global.Get<bool> (nameof(DebugLogOnStartup));
set {
- if (DbgLogger.ConsoleOutput != value)
- return;
+ if (DebugLogOnStartup == value)
+ return;
Configuration.Global.Set (nameof(DebugLogOnStartup), value);
NotifyValueChanged(DebugLogOnStartup);
}
diff --git a/Samples/DebugLogAnalyzer/ui/DebugLog.crow b/Samples/DebugLogAnalyzer/ui/DebugLog.crow
index 2b5ab978..a4e947af 100644
--- a/Samples/DebugLogAnalyzer/ui/DebugLog.crow
+++ b/Samples/DebugLogAnalyzer/ui/DebugLog.crow
@@ -31,7 +31,7 @@
<Label Style="smallLabValue" Tooltip="VisibleTicks" Text="{../../dbv.VisibleTicks}"/>
</HorizontalStack>
</VerticalStack>
- <!--<VerticalStack Name="AllEvents" Width="Stretched" IsVisible="false">
+ <VerticalStack Name="AllEvents" Width="Stretched" IsVisible="false">
<TreeView Height="Stretched" Name="dbgTV" Data="{Events}" SelectedItem="{²CurrentEvent}" Background="DarkGrey"
ItemTemplate="#Dbg.DbgEventTreeItems.itemp"/>
<ListBox Data="{CurWidgetEvents}" Height="100" SelectedItem="{²CurrentEvent}">
@@ -50,7 +50,7 @@
<VerticalStack Name="CurWidgetEvents" Width="Stretched" IsVisible="false">
<TreeView Height="Stretched" Data="{CurrentWidgetEvents}" Background="DarkGrey"
ItemTemplate="#Dbg.DbgEventTreeItems.itemp"/>
- </VerticalStack>-->
+ </VerticalStack>
</TabView>
<Splitter/>
<HorizontalStack Height="30%">