From d72836f3a089bc1aeb48510a6f0a43d078d60330 Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Thu, 27 Feb 2014 16:41:52 -0800 Subject: [PATCH] Make sure we don't keep a reference around to widgets through the OnIdle call back. --- ActionBar/PrintStatusRow.cs | 5 ++++- ControlElements/MHTextEditWidget.cs | 10 ++++++++-- CustomWidgets/PrintProgressBarWidget.cs | 6 +++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ActionBar/PrintStatusRow.cs b/ActionBar/PrintStatusRow.cs index f51d37ef1..909ca8ccb 100644 --- a/ActionBar/PrintStatusRow.cs +++ b/ActionBar/PrintStatusRow.cs @@ -218,7 +218,10 @@ namespace MatterHackers.MatterControl.ActionBar } } - UiThread.RunOnIdle(OnIdle); + if (!WidgetHasBeenClosed) + { + UiThread.RunOnIdle(OnIdle); + } } void Instance_WroteLine(object sender, EventArgs e) diff --git a/ControlElements/MHTextEditWidget.cs b/ControlElements/MHTextEditWidget.cs index fa10e7614..b314190cd 100644 --- a/ControlElements/MHTextEditWidget.cs +++ b/ControlElements/MHTextEditWidget.cs @@ -76,7 +76,10 @@ namespace MatterHackers.MatterControl timeSinceLastTextChanged.Stop(); } - UiThread.RunOnIdle(OnIdle); + if (!WidgetHasBeenClosed) + { + UiThread.RunOnIdle(OnIdle); + } } void internalTextEditWidget_TextChanged(object sender, EventArgs e) @@ -155,7 +158,10 @@ namespace MatterHackers.MatterControl timeSinceLastTextChanged.Stop(); } - UiThread.RunOnIdle(OnIdle); + if (!WidgetHasBeenClosed) + { + UiThread.RunOnIdle(OnIdle); + } } void internalNumberEdit_TextChanged(object sender, EventArgs e) diff --git a/CustomWidgets/PrintProgressBarWidget.cs b/CustomWidgets/PrintProgressBarWidget.cs index 847a42060..81974ea7f 100644 --- a/CustomWidgets/PrintProgressBarWidget.cs +++ b/CustomWidgets/PrintProgressBarWidget.cs @@ -122,7 +122,11 @@ namespace MatterHackers.MatterControl UpdatePrintStatus(); } - UiThread.RunOnIdle(OnIdle); + + if (!WidgetHasBeenClosed) + { + UiThread.RunOnIdle(OnIdle); + } } private void UpdatePrintStatus()