From 799f7396d22648f7d3a77591427a18e93cccb627 Mon Sep 17 00:00:00 2001 From: Ani <115020168+drawbyperpetual@users.noreply.github.com> Date: Wed, 18 Dec 2024 20:31:20 +0100 Subject: [PATCH] [AdvancedPaste]Fix NullReferenceException on Dispose (#36428) [AdvancedPaste] Fixed NullReferenceException on Dispose --- .../AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/App.xaml.cs | 2 +- .../AdvancedPaste/AdvancedPaste/Helpers/UserSettings.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/App.xaml.cs b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/App.xaml.cs index 327558ad9fa9..3ac3baa9d0e6 100644 --- a/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/App.xaml.cs +++ b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/App.xaml.cs @@ -263,7 +263,7 @@ protected virtual void Dispose(bool disposing) if (disposing) { EtwTrace?.Dispose(); - window.Dispose(); + window?.Dispose(); } disposedValue = true; diff --git a/src/modules/AdvancedPaste/AdvancedPaste/Helpers/UserSettings.cs b/src/modules/AdvancedPaste/AdvancedPaste/Helpers/UserSettings.cs index e2c2e07c843d..8d5f51314db5 100644 --- a/src/modules/AdvancedPaste/AdvancedPaste/Helpers/UserSettings.cs +++ b/src/modules/AdvancedPaste/AdvancedPaste/Helpers/UserSettings.cs @@ -154,8 +154,8 @@ private void Dispose(bool disposing) { if (disposing) { - _cancellationTokenSource.Dispose(); - _watcher.Dispose(); + _cancellationTokenSource?.Dispose(); + _watcher?.Dispose(); } _disposedValue = true;