diff options
author | nosami <jasonimison@gmail.com> | 2019-12-06 13:32:41 +0300 |
---|---|---|
committer | nosami <jasonimison@gmail.com> | 2019-12-06 13:32:41 +0300 |
commit | 3c55ef35000b0c721a07f1974d83a966da72f6a5 (patch) | |
tree | 02ffdcedf2918fda2b3d0ec2010b1ca662e260ad /main/src | |
parent | 717546659d0c7b5a01d48e700efe8d6fbf16f4a0 (diff) |
Dispose eventhandlers when page is disposed
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore.Scaffolding/ScaffolderTemplateSelectPage.cs | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore.Scaffolding/ScaffolderTemplateSelectPage.cs b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore.Scaffolding/ScaffolderTemplateSelectPage.cs index f721d9ad6a..4cd74a41a4 100644 --- a/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore.Scaffolding/ScaffolderTemplateSelectPage.cs +++ b/main/src/addins/MonoDevelop.AspNetCore/MonoDevelop.AspNetCore.Scaffolding/ScaffolderTemplateSelectPage.cs @@ -24,8 +24,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; -using System.Threading; -using System.Threading.Tasks; using MonoDevelop.Core; using MonoDevelop.Ide; using Xwt; @@ -36,12 +34,14 @@ namespace MonoDevelop.AspNetCore.Scaffolding class ScaffolderTemplateSelectPage : ScaffolderWizardPageBase { ListBox listBox; - ScaffolderArgs args; + readonly ScaffolderArgs args; + ScaffolderBase [] scaffolders; public event EventHandler ScaffolderSelected; + public ScaffolderTemplateSelectPage (ScaffolderArgs args) : base (args) { - this.SubSubTitle = GettextCatalog.GetString ("Select Scaffolder"); + SubSubTitle = GettextCatalog.GetString ("Select Scaffolder"); this.args = args; } @@ -67,7 +67,7 @@ namespace MonoDevelop.AspNetCore.Scaffolding var listStore = new ListStore (icon, name); - var scaffolders = GetScaffolders ().Value; + scaffolders = GetScaffolders ().Value; foreach (var scaffolder in scaffolders) { var row = listStore.AddRow (); @@ -84,12 +84,31 @@ namespace MonoDevelop.AspNetCore.Scaffolding listBox.DataSource = listStore; listBox.HeightRequest = 300; listBox.WidthRequest = 300; - listBox.SelectionChanged += (sender, e) => Args.Scaffolder = scaffolders [listBox.SelectedRow]; - listBox.RowActivated += (sender, e) => ScaffolderSelected?.Invoke (sender, e); + listBox.SelectionChanged += SelectionChanged; + listBox.RowActivated += RowActivated; listBox.SelectRow (0); listBox.FocusedRow = 0; listBox.SetFocus (); return listBox; } - } + + void SelectionChanged(object sender, EventArgs e) + { + Args.Scaffolder = scaffolders [listBox.SelectedRow]; + } + + void RowActivated (object sender, EventArgs e) + { + ScaffolderSelected?.Invoke (sender, e); + } + + protected override void Dispose (bool disposing) + { + if (listBox != null) { + listBox.SelectionChanged -= SelectionChanged; + listBox.RowActivated -= RowActivated; + } + base.Dispose (disposing); + } + } } |