Skip to content

Fix bitmap disposal leaks and isDrawing stuck state from PR review#631

Merged
TheJoeFin merged 3 commits intoui-automationfrom
copilot/sub-pr-630
Mar 8, 2026
Merged

Fix bitmap disposal leaks and isDrawing stuck state from PR review#631
TheJoeFin merged 3 commits intoui-automationfrom
copilot/sub-pr-630

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 8, 2026

Addresses four issues flagged in the PR review for the UI Automation / Direct Text feature.

Changes

  • GDI bitmap leaksBitmap bmp in GetRegionsTextAsTableAsync and GetOcrResultFromRegionAsync was never disposed. Added using declarations to ensure disposal on all code paths (WindowsAI early-return and standard OCR path).
// Before
Bitmap bmp = ImageMethods.GetRegionOfScreenAsBitmap(region);

// After
using Bitmap bmp = ImageMethods.GetRegionOfScreenAsBitmap(region);
  • isDrawing stuck after null OCR resultDrawOcrRectanglesAsync returned early when ocrResultOfWindow was null without resetting isDrawing = false or restarting reDrawTimer, permanently blocking future redraws. Now matches the same reset pattern used for the invalid canvas-size early return above it.

  • ClearRenderedWordBorders() misleading indentation — The call was indented as if inside the braceless if (!hasLoadedImageSource) block but always executed unconditionally. Fixed indentation to reflect actual control flow.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…ents

Co-authored-by: TheJoeFin <7809853+TheJoeFin@users.noreply.github.com>
Copilot AI changed the title [WIP] Add UI automation to grab direct text from UI elements Fix bitmap disposal leaks and isDrawing stuck state from PR review Mar 8, 2026
Disposing selectionBitmap with a using statement caused app crashes.
Now, the bitmap is not disposed immediately, and a comment was
added to highlight the issue and the need for further investigation.
@TheJoeFin TheJoeFin marked this pull request as ready for review March 8, 2026 01:42
@TheJoeFin TheJoeFin merged commit fa135cb into ui-automation Mar 8, 2026
@TheJoeFin TheJoeFin deleted the copilot/sub-pr-630 branch March 8, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants