diff --git a/src/BizHawk.Client.EmuHawk/movie/EditCommentsForm.Designer.cs b/src/BizHawk.Client.EmuHawk/movie/EditCommentsForm.Designer.cs index 397735db0e..dad4491197 100644 --- a/src/BizHawk.Client.EmuHawk/movie/EditCommentsForm.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/movie/EditCommentsForm.Designer.cs @@ -109,6 +109,7 @@ this.Name = "EditCommentsForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Edit Comments"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnClosed); this.Load += new System.EventHandler(this.EditCommentsForm_Load); ((System.ComponentModel.ISupportInitialize)(this.CommentGrid)).EndInit(); this.ResumeLayout(false); diff --git a/src/BizHawk.Client.EmuHawk/movie/EditCommentsForm.cs b/src/BizHawk.Client.EmuHawk/movie/EditCommentsForm.cs index 40107cfca9..449199372d 100644 --- a/src/BizHawk.Client.EmuHawk/movie/EditCommentsForm.cs +++ b/src/BizHawk.Client.EmuHawk/movie/EditCommentsForm.cs @@ -12,13 +12,15 @@ namespace BizHawk.Client.EmuHawk private readonly bool _readOnly; private string _lastHeaderClicked; private bool _sortReverse; + private readonly bool _dispose; - public EditCommentsForm(IMovie movie, bool readOnly) + public EditCommentsForm(IMovie movie, bool readOnly, bool disposeOnClose = false) { _movie = movie; _readOnly = readOnly; _lastHeaderClicked = ""; _sortReverse = false; + _dispose = disposeOnClose; InitializeComponent(); Icon = Properties.Resources.TAStudioIcon; @@ -99,5 +101,13 @@ namespace BizHawk.Client.EmuHawk _sortReverse = !_sortReverse; CommentGrid.Refresh(); } + + private void OnClosed(object sender, FormClosedEventArgs e) + { + if (_dispose && _movie is ITasMovie tasMovie) + { + tasMovie.Dispose(); + } + } } } diff --git a/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.Designer.cs b/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.Designer.cs index 4f86c3962c..704c97eb7c 100644 --- a/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.Designer.cs @@ -199,6 +199,7 @@ this.Name = "EditSubtitlesForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Edit Subtitles"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnClosed); this.Load += new System.EventHandler(this.EditSubtitlesForm_Load); ((System.ComponentModel.ISupportInitialize)(this.SubGrid)).EndInit(); this.ResumeLayout(false); diff --git a/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.cs b/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.cs index 17c351be9e..d903ebd763 100644 --- a/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.cs +++ b/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.cs @@ -17,14 +17,16 @@ namespace BizHawk.Client.EmuHawk private readonly IMovie _selectedMovie; private readonly bool _readOnly; + private readonly bool _dispose; public IDialogController DialogController { get; } - public EditSubtitlesForm(IDialogController dialogController, IMovie movie, PathEntryCollection pathEntries, bool readOnly) + public EditSubtitlesForm(IDialogController dialogController, IMovie movie, PathEntryCollection pathEntries, bool readOnly, bool disposeOnClose = false) { _pathEntries = pathEntries; _selectedMovie = movie; _readOnly = readOnly; + _dispose = disposeOnClose; DialogController = dialogController; InitializeComponent(); Icon = Properties.Resources.TAStudioIcon; @@ -271,5 +273,13 @@ namespace BizHawk.Client.EmuHawk } } } + + private void OnClosed(object sender, FormClosedEventArgs e) + { + if (_dispose && _selectedMovie is ITasMovie tasMovie) + { + tasMovie.Dispose(); + } + } } } diff --git a/src/BizHawk.Client.EmuHawk/movie/PlayMovie.cs b/src/BizHawk.Client.EmuHawk/movie/PlayMovie.cs index 0f42b38076..f5a55cbd6a 100644 --- a/src/BizHawk.Client.EmuHawk/movie/PlayMovie.cs +++ b/src/BizHawk.Client.EmuHawk/movie/PlayMovie.cs @@ -525,8 +525,7 @@ namespace BizHawk.Client.EmuHawk // TODO this will allocate unnecessary memory when this movie is a TasMovie due to TasStateManager var movie = _movieSession.Get(_movieList[MovieView.SelectedIndices[0]].Filename); movie.Load(); - // TODO movie should be disposed if movie is ITasMovie - var form = new EditCommentsForm(movie, _movieSession.ReadOnly); + var form = new EditCommentsForm(movie, readOnly: false, disposeOnClose: true); form.Show(); } } @@ -539,8 +538,7 @@ namespace BizHawk.Client.EmuHawk // TODO this will allocate unnecessary memory when this movie is a TasMovie due to TasStateManager var movie = _movieSession.Get(_movieList[MovieView.SelectedIndices[0]].Filename); movie.Load(); - // TODO movie should be disposed if movie is ITasMovie - var form = new EditSubtitlesForm(DialogController, movie, _config.PathEntries, readOnly: true); + var form = new EditSubtitlesForm(DialogController, movie, _config.PathEntries, readOnly: false, disposeOnClose: true); form.Show(); } }