Skip to content

Commit

Permalink
fix(Program): Crash when stopping the application
Browse files Browse the repository at this point in the history
Fixes SOUNDSWITCH-1
  • Loading branch information
Belphemur committed May 9, 2021
1 parent 3e2fe17 commit 8da165d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 7 additions & 0 deletions SoundSwitch/Model/AppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -480,5 +480,12 @@ public NoDevicesException() : base("No devices to select")
}

#endregion

public void Dispose()
{
TrayIcon?.Dispose();
ActiveAudioDeviceLister?.Dispose();
ActiveUnpluggedAudioLister?.Dispose();
}
}
}
2 changes: 1 addition & 1 deletion SoundSwitch/Model/IAppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

namespace SoundSwitch.Model
{
public interface IAppModel
public interface IAppModel : IDisposable
{
#region Properties

Expand Down
6 changes: 2 additions & 4 deletions SoundSwitch/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,9 @@ private static void Main()
HandleException(ex);
}
#endif
AppModel.Instance.ActiveAudioDeviceLister.Dispose();
AppModel.Instance.ActiveUnpluggedAudioLister.Dispose();
AppModel.Instance.TrayIcon.Dispose();
AppModel.Instance.Dispose();
WindowsAPIAdapter.Stop();
MMNotificationClient.Instance.Dispose();
MMNotificationClient.Instance?.Dispose();
Log.CloseAndFlush();
}

Expand Down

0 comments on commit 8da165d

Please sign in to comment.