From 2590ea5bdbaef568b79c87a4d4ad65e97a9198da Mon Sep 17 00:00:00 2001 From: CJK_mkp <113243675+CJKmkp@users.noreply.github.com> Date: Mon, 23 Mar 2026 16:46:28 +0800 Subject: [PATCH] Fix PPT disconnect null check crash (#413) --- Ink Canvas/Helpers/ROTPPTManager.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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; }