From d092b171d362ddc8332fd3bb2de7143335230ad4 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 20 Nov 2023 23:15:09 +0100 Subject: [PATCH] Clear lists of variables on close to prevent loading on closed windows --- solution/GraphicalDebugging/GeometryWatch.cs | 6 ++++++ solution/GraphicalDebugging/GeometryWatchControl.xaml.cs | 5 +++++ solution/GraphicalDebugging/GraphicalWatch.cs | 6 ++++++ solution/GraphicalDebugging/GraphicalWatchControl.xaml.cs | 5 +++++ solution/GraphicalDebugging/PlotWatch.cs | 6 ++++++ solution/GraphicalDebugging/PlotWatchControl.xaml.cs | 5 +++++ 6 files changed, 33 insertions(+) diff --git a/solution/GraphicalDebugging/GeometryWatch.cs b/solution/GraphicalDebugging/GeometryWatch.cs index 61c5eb9..d395140 100644 --- a/solution/GraphicalDebugging/GeometryWatch.cs +++ b/solution/GraphicalDebugging/GeometryWatch.cs @@ -36,5 +36,11 @@ public GeometryWatch() : base(null) // the object returned by the Content property. this.Content = new GeometryWatchControl(); } + + protected override void OnClose() + { + (this.Content as GeometryWatchControl).OnClose(); + base.OnClose(); + } } } diff --git a/solution/GraphicalDebugging/GeometryWatchControl.xaml.cs b/solution/GraphicalDebugging/GeometryWatchControl.xaml.cs index d6c6f7b..7c5a441 100644 --- a/solution/GraphicalDebugging/GeometryWatchControl.xaml.cs +++ b/solution/GraphicalDebugging/GeometryWatchControl.xaml.cs @@ -563,5 +563,10 @@ private void dataGridContextMenuDisable_Click(object sender, RoutedEventArgs e) Util.EnableDataGridItems(dataGrid, Geometries, (GeometryItem geometry) => geometry.IsEnabled = false); } + + public void OnClose() + { + Geometries.Clear(); + } } } \ No newline at end of file diff --git a/solution/GraphicalDebugging/GraphicalWatch.cs b/solution/GraphicalDebugging/GraphicalWatch.cs index f07f4aa..715f8e4 100644 --- a/solution/GraphicalDebugging/GraphicalWatch.cs +++ b/solution/GraphicalDebugging/GraphicalWatch.cs @@ -36,5 +36,11 @@ public GraphicalWatch() : base(null) // the object returned by the Content property. this.Content = new GraphicalWatchControl(); } + + protected override void OnClose() + { + (this.Content as GraphicalWatchControl).OnClose(); + base.OnClose(); + } } } diff --git a/solution/GraphicalDebugging/GraphicalWatchControl.xaml.cs b/solution/GraphicalDebugging/GraphicalWatchControl.xaml.cs index af5ffd5..69726cb 100644 --- a/solution/GraphicalDebugging/GraphicalWatchControl.xaml.cs +++ b/solution/GraphicalDebugging/GraphicalWatchControl.xaml.cs @@ -280,5 +280,10 @@ private void dataGridContextMenuDelete_Click(object sender, RoutedEventArgs e) (GraphicalItem variable) => { }, () => { }); } + + public void OnClose() + { + Variables.Clear(); + } } } diff --git a/solution/GraphicalDebugging/PlotWatch.cs b/solution/GraphicalDebugging/PlotWatch.cs index 5e972ef..6dcfe32 100644 --- a/solution/GraphicalDebugging/PlotWatch.cs +++ b/solution/GraphicalDebugging/PlotWatch.cs @@ -36,5 +36,11 @@ public PlotWatch() : base(null) // the object returned by the Content property. this.Content = new PlotWatchControl(); } + + protected override void OnClose() + { + (this.Content as PlotWatchControl).OnClose(); + base.OnClose(); + } } } diff --git a/solution/GraphicalDebugging/PlotWatchControl.xaml.cs b/solution/GraphicalDebugging/PlotWatchControl.xaml.cs index d4d79bf..d1dd2f7 100644 --- a/solution/GraphicalDebugging/PlotWatchControl.xaml.cs +++ b/solution/GraphicalDebugging/PlotWatchControl.xaml.cs @@ -571,5 +571,10 @@ private void dataGridContextMenuDisable_Click(object sender, RoutedEventArgs e) Util.EnableDataGridItems(dataGrid, Plots, (PlotItem plot) => plot.IsEnabled = false); } + + public void OnClose() + { + Plots.Clear(); + } } } \ No newline at end of file