Skip to content

a couple places where ArtQRCode creates a short lived Bitmap but neve…#695

Open
danFbach wants to merge 1 commit intoShane32:masterfrom
danFbach:gdi+-handle-leaks
Open

a couple places where ArtQRCode creates a short lived Bitmap but neve…#695
danFbach wants to merge 1 commit intoShane32:masterfrom
danFbach:gdi+-handle-leaks

Conversation

@danFbach
Copy link
Copy Markdown

@danFbach danFbach commented Apr 6, 2026

…r disposes of it and orphans the GDI+ handle, leading to handle exhaustion in some cases.

Summary

wraps internal throw away bitmaps in using blocks so that they are disposed of.

This PR fixes/implements the following bugs/features:

  • BUG GDI+ handle leakages

What existing problem does the pull request solve?

when i recursively generate ArtQRCode(s) i get handle exhaustion errors which show themselves as "A generic error occurred in GDI+."

Test plan

Passes project unit tests. Simple using blocks added to internal objects only, so it should not change how anything works.

Closing issues

didn't create an issue.

Summary by CodeRabbit

  • Bug Fixes
    • Improved resource management during QR code generation to ensure temporary graphics objects used for rendering are properly disposed, enhancing application stability and preventing potential memory-related issues.

…r disposes of it and orphans the GDI+ handle, leading to handle exhaustion in some cases.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bcc08796-de1a-43e1-9617-668937659e7a

📥 Commits

Reviewing files that changed from the base of the PR and between 443d5a1 and 0090cb5.

📒 Files selected for processing (1)
  • QRCoder/ArtQRCode.cs

📝 Walkthrough

Walkthrough

Updated resource management in ArtQRCode class by wrapping intermediate Bitmap allocations in using var statements throughout GetGraphic, MakeDotPixel, and Resize methods to ensure deterministic disposal of graphics resources.

Changes

Cohort / File(s) Summary
Resource Management
QRCoder/ArtQRCode.cs
Introduced using var statements for scoped Bitmap disposals in background image drawing operations and dot pixel rendering. Modified GetGraphic, MakeDotPixel, and Resize methods to manage temporary bitmap allocations with deterministic cleanup.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is incomplete and truncated with '...' but clearly refers to the main change: addressing short-lived Bitmap instances in ArtQRCode that were not being disposed.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant