Skip to content

Commit 2ecc7cd

Browse files
committed
Fixed Bug: if Plot was closed it could not be recreated
1 parent e314555 commit 2ecc7cd

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

TRA.Lib/Trasse.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ public void SaveCSV(StreamWriter outputFile)
308308
ScottPlot.WinForms.FormsPlot PlotG;
309309
/// <value>Table for all loaded Attributes of the TRA-File</value>
310310
DataGridView gridView;
311-
312311
public void Plot()
313312
{
314313
if (Form == null)
@@ -358,9 +357,9 @@ public void Plot()
358357
BtnPanel.Controls.Add(CheckElementLabels);
359358
BtnPanel.Controls.Add(CheckShowWarnings);
360359
BtnPanel.Controls.Add(CheckProjections);
361-
splitContainer.Panel2.Controls.Add(tabControl);
362-
360+
splitContainer.Panel2.Controls.Add(tabControl);
363361
}
362+
Form.FormClosing += (sender, e) => OnFormClosed();
364363
//Add Plot for 2D overview
365364
PixelPadding padding = new(80, 80, 20, 5);
366365
if (Plot2D == null)
@@ -591,6 +590,15 @@ public void Plot()
591590
Form.Update();
592591
}
593592

593+
private void OnFormClosed()
594+
{
595+
Plottables.Clear();
596+
selectedS = null; PlotT = null; PlotG = null;
597+
gridView = null;
598+
Plot2D = null;
599+
Form = null;
600+
}
601+
594602
public void UpdatePlot()
595603
{
596604
if (gridView != null)
@@ -604,7 +612,8 @@ public void UpdatePlot()
604612

605613
}
606614
private void Warning_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
607-
{
615+
{
616+
if (Plot2D == null) return;
608617
switch (e.Action)
609618
{
610619
case NotifyCollectionChangedAction.Add:

0 commit comments

Comments
 (0)