fix: stabilize PPT slideshow state sync on transient COM states#394
fix: stabilize PPT slideshow state sync on transient COM states#394
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32f1d95585
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (knownSlideShowWindow != null) | ||
| { | ||
| slideShowWindow = ssw[1]; | ||
| if (slideShowWindow != null) | ||
| slideShowWindow = knownSlideShowWindow; | ||
| } |
There was a problem hiding this comment.
Avoid releasing the slideshow event window instance
When knownSlideShowWindow is provided, this branch stores the caller-owned event argument in slideShowWindow, and UpdateCurrentPresentationInfo later calls SafeReleaseComObject(slideShowWindow) in finally. In OnSlideShowBegin/OnSlideShowNextSlide, that means wn can be released before SlideShowBegin?.Invoke(wn) or SlideShowNextSlide?.Invoke(wn), so handlers that access COM members like wn.View may hit InvalidComObjectException during normal slideshow events.
Useful? React with 👍 / 👎.
| dynamic sswObj = slideShowWindow; | ||
| return sswObj.Presentation; |
There was a problem hiding this comment.
Release COM references before returning presentation fallback
The fallback path in TryGetActivePresentation returns sswObj.Presentation directly without any finally cleanup for the temporary SlideShowWindows/SlideShowWindow COM objects created earlier in the method. Because this helper is now called on each presentation-state refresh, those unreleased COM references can accumulate and keep PowerPoint objects alive longer than expected, degrading stability over time.
Useful? React with 👍 / 👎.
Motivation
0x80048240(no active presentation/document window) and cause controls to disappear or the app to hang.ActiveWindow/ActivePresentationduring slideshow transitions where those COM properties may be temporarily unavailable, preventing cascade failures and slow/blocked behavior.Description
IsNoActivePresentationOrWindowHResultto treat0x80048240as a transient condition rather than a hard error.UpdateCurrentPresentationInfoslideshow-aware by adding parameterspreferSlideShowWindowandknownSlideShowWindowso slideshow events can provide a stableSlideShowWindowcontext.TryGetActivePresentationthat first attemptsActivePresentationand falls back to reading thePresentationfrom aSlideShowWindow(or the firstSlideShowWindowsentry) whenActivePresentationthrows0x80048240.OnSlideShowBeginandOnSlideShowNextSlideto pass the eventSlideShowWindowintoUpdateCurrentPresentationInfo, and relax COM-exception logging to ignore the transient0x80048240case.Testing
dotnet --versionin the current environment to attempt a build/runtime check, which failed withdotnet: command not foundso no automated .NET tests could be executed here.Codex Task