Fix disposed icon crash#268
Merged
Merged
Conversation
Root cause: Icons obtained from Resources.ResourceManager are managed resources that should not be manually disposed. When we called Dispose() on these icons: 1. NotifyIcon still held references to the disposed icons 2. Any access to NotifyIcon properties (Text, Icon, etc.) would trigger ObjectDisposedException 3. This commonly occurred during app launch, sleep/wake, and theme changes when SetIcons() ran concurrently with AdvanceFrame() Solution: Remove all icon.Dispose() calls in SetIcons() and Dispose() methods. ResourceManager handles the lifecycle of these resources, and the GC will properly clean them up. This fix resolves crashes reported in GitHub issues where users experienced "Cannot access a disposed object. Object name: 'Icon'" errors during startup and after sleep/wake cycles. Testing: Verified with stress testing (100 iterations of rapid icon switching with 5ms delays) that previously reproduced the crash 100% of the time. After this fix, no crashes occurred in 15+ test runs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
8 tasks
Closed
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context of Contribution
fix #236
Summary of the Proposal
Since I have established a way to reproduce the issue, I have identified the cause and fixed it.
There is no need to manually dispose of the NotifyIcon's Icon.
Reason for the new feature
Checklist