diff options
author | Jason Imison <nosami@users.noreply.github.com> | 2019-12-06 18:15:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-06 18:15:39 +0300 |
commit | 280d310f65777e54f21774e9440c7c2b585d1d38 (patch) | |
tree | 18567be2286ed63ba138f6fb0c62522ba6df1805 /main/src | |
parent | 198cfdda5681f7f818033c88468b7d6cfe2ff2d1 (diff) | |
parent | 3c55ef35000b0c721a07f1974d83a966da72f6a5 (diff) |
Merge pull request #9441 from mono/minor-scaffolder-clean-up
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); + } + } } |