Skip to content

Commit

Permalink
Adjust ExplorerMonitor lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
dremin committed Nov 16, 2024
1 parent 2aca5a3 commit 24715e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 6 additions & 3 deletions RetroBar/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ namespace RetroBar
public partial class App : Application
{
private bool _errorVisible;
private DictionaryManager _dictionaryManager;
private ManagedShellLogger _logger;
private WindowManager _windowManager;

private readonly StartMenuMonitor _startMenuMonitor;
private readonly DictionaryManager _dictionaryManager;
private readonly ExplorerMonitor _explorerMonitor;
private readonly ShellManager _shellManager;
private readonly StartMenuMonitor _startMenuMonitor;
private readonly Updater _updater;

public App()
{
_shellManager = SetupManagedShell();

_explorerMonitor = new ExplorerMonitor();
_startMenuMonitor = new StartMenuMonitor(new AppVisibilityHelper(false));
_dictionaryManager = new DictionaryManager();
_updater = new Updater();
Expand All @@ -55,7 +57,7 @@ private void App_OnStartup(object sender, StartupEventArgs e)

_dictionaryManager.SetLanguageFromSettings();
loadTheme();
_windowManager = new WindowManager(_dictionaryManager, _shellManager, _startMenuMonitor, _updater);
_windowManager = new WindowManager(_dictionaryManager, _explorerMonitor, _shellManager, _startMenuMonitor, _updater);
}

private void App_OnExit(object sender, ExitEventArgs e)
Expand Down Expand Up @@ -135,6 +137,7 @@ private void ExitApp()
{
Settings.Instance.PropertyChanged -= Settings_PropertyChanged;

_explorerMonitor.Dispose();
_windowManager.Dispose();
_dictionaryManager.Dispose();
_shellManager.Dispose();
Expand Down
11 changes: 5 additions & 6 deletions RetroBar/Utilities/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ public class WindowManager : IDisposable
private List<Taskbar> _taskbars = new List<Taskbar>();

private readonly DictionaryManager _dictionaryManager;
private readonly ExplorerMonitor _explorerMonitor;
private readonly StartMenuMonitor _startMenuMonitor;
private readonly ShellManager _shellManager;
private readonly Updater _updater;

private readonly ExplorerMonitor _explorerMonitor = new();

public WindowManager(DictionaryManager dictionaryManager, ShellManager shellManager, StartMenuMonitor startMenuMonitor, Updater updater)
public WindowManager(DictionaryManager dictionaryManager, ExplorerMonitor explorerMonitor, ShellManager shellManager, StartMenuMonitor startMenuMonitor, Updater updater)
{
_dictionaryManager = dictionaryManager;
_explorerMonitor = explorerMonitor;
_shellManager = shellManager;
_startMenuMonitor = startMenuMonitor;
_updater = updater;

_explorerMonitor.ExplorerMonitorStart(this);

_shellManager.ExplorerHelper.HideExplorerTaskbar = true;

openTaskbars();

_explorerMonitor.ExplorerMonitorStart(this);

Settings.Instance.PropertyChanged += Settings_PropertyChanged;
}

Expand Down Expand Up @@ -189,7 +189,6 @@ private void resetScreenCache()

public void Dispose()
{
_explorerMonitor?.Dispose();
_shellManager.ExplorerHelper.HideExplorerTaskbar = false;
Settings.Instance.PropertyChanged -= Settings_PropertyChanged;
}
Expand Down

0 comments on commit 24715e7

Please sign in to comment.