From d75dd71848d727c24d882624b307f85d19326149 Mon Sep 17 00:00:00 2001 From: Divyansh Srivastava Date: Mon, 14 Sep 2020 11:03:17 -0700 Subject: [PATCH] Fix for null reference exception (#6589) --- src/modules/launcher/PowerLauncher/App.xaml.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/modules/launcher/PowerLauncher/App.xaml.cs b/src/modules/launcher/PowerLauncher/App.xaml.cs index 8301943d91..c8a1623c1f 100644 --- a/src/modules/launcher/PowerLauncher/App.xaml.cs +++ b/src/modules/launcher/PowerLauncher/App.xaml.cs @@ -173,13 +173,17 @@ namespace PowerLauncher Log.Info("|App.OnExit| Start PowerToys Run Exit---------------------------------------------------- "); if (disposing) { - _themeManager.ThemeChanged -= OnThemeChanged; - API.SaveAppAllSettings(); + if (_themeManager != null) + { + _themeManager.ThemeChanged -= OnThemeChanged; + } + + API?.SaveAppAllSettings(); PluginManager.Dispose(); - _mainWindow.Dispose(); - API.Dispose(); - _mainVM.Dispose(); - _themeManager.Dispose(); + _mainWindow?.Dispose(); + API?.Dispose(); + _mainVM?.Dispose(); + _themeManager?.Dispose(); _disposed = true; }