From 01093860493b252e3707cfc99c775b92e6ea1302 Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 27 Aug 2020 09:22:30 -0500 Subject: [PATCH] dispose of TasStateManager --- src/BizHawk.Client.Common/movie/MovieSession.cs | 5 +++++ src/BizHawk.Client.Common/movie/interfaces/ITasMovie.cs | 2 +- src/BizHawk.Client.Common/movie/tasproj/IStateManager.cs | 5 +++-- src/BizHawk.Client.Common/movie/tasproj/TasMovie.cs | 6 ++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/BizHawk.Client.Common/movie/MovieSession.cs b/src/BizHawk.Client.Common/movie/MovieSession.cs index 452c3b0306..c0750dcdd4 100644 --- a/src/BizHawk.Client.Common/movie/MovieSession.cs +++ b/src/BizHawk.Client.Common/movie/MovieSession.cs @@ -277,6 +277,11 @@ namespace BizHawk.Client.Common _modeChangedCallback(); } + if (Movie is IDisposable d) + { + d.Dispose(); + } + Movie = null; } diff --git a/src/BizHawk.Client.Common/movie/interfaces/ITasMovie.cs b/src/BizHawk.Client.Common/movie/interfaces/ITasMovie.cs index 9287fe0a53..33bfb4da11 100644 --- a/src/BizHawk.Client.Common/movie/interfaces/ITasMovie.cs +++ b/src/BizHawk.Client.Common/movie/interfaces/ITasMovie.cs @@ -6,7 +6,7 @@ using BizHawk.Emulation.Common; namespace BizHawk.Client.Common { - public interface ITasMovie : IMovie, INotifyPropertyChanged + public interface ITasMovie : IMovie, INotifyPropertyChanged, IDisposable { bool BindMarkersToInput { get; set; } bool LastPositionStable { get; set; } diff --git a/src/BizHawk.Client.Common/movie/tasproj/IStateManager.cs b/src/BizHawk.Client.Common/movie/tasproj/IStateManager.cs index 86cc34298a..46126a1abb 100644 --- a/src/BizHawk.Client.Common/movie/tasproj/IStateManager.cs +++ b/src/BizHawk.Client.Common/movie/tasproj/IStateManager.cs @@ -1,10 +1,11 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using BizHawk.Emulation.Common; namespace BizHawk.Client.Common { - public interface IStateManager + public interface IStateManager : IDisposable { /// /// Retrieves the savestate for the given frame, diff --git a/src/BizHawk.Client.Common/movie/tasproj/TasMovie.cs b/src/BizHawk.Client.Common/movie/tasproj/TasMovie.cs index 1357dd2f63..7642d6f08d 100644 --- a/src/BizHawk.Client.Common/movie/tasproj/TasMovie.cs +++ b/src/BizHawk.Client.Common/movie/tasproj/TasMovie.cs @@ -350,5 +350,11 @@ namespace BizHawk.Client.Common return Markers.Any(m => m.Frame - 1 == frame) || Branches.Any(b => b.Frame == frame); // Branches should already be in the reserved list, but it doesn't hurt to check } + + public void Dispose() + { + TasStateManager?.Dispose(); + TasStateManager = null; + } } }