diff --git a/Ink Canvas/Helpers/ROTPPTManager.cs b/Ink Canvas/Helpers/ROTPPTManager.cs index 333de9b2..4044058a 100644 --- a/Ink Canvas/Helpers/ROTPPTManager.cs +++ b/Ink Canvas/Helpers/ROTPPTManager.cs @@ -1344,10 +1344,22 @@ namespace Ink_Canvas.Helpers catch { } } + private static bool IsObjectNull(object comObject) + { + return ReferenceEquals(comObject, null); + } + private void DisconnectFromPPT() { - if (PPTApplication == null && _pptActivePresentation == null && _pptSlideShowWindow == null && - CurrentPresentation == null && CurrentSlides == null && CurrentSlide == null) + object pptApplication = PPTApplication; + object activePresentation = _pptActivePresentation; + object slideShowWindow = _pptSlideShowWindow; + object currentPresentation = CurrentPresentation; + object currentSlides = CurrentSlides; + object currentSlide = CurrentSlide; + + if (IsObjectNull(pptApplication) && IsObjectNull(activePresentation) && IsObjectNull(slideShowWindow) && + IsObjectNull(currentPresentation) && IsObjectNull(currentSlides) && IsObjectNull(currentSlide)) { return; }