Fix memory leak / assertion error when switching to schemas with custom icons#1836
Open
cqjjjzr wants to merge 1 commit intorime:masterfrom
Open
Fix memory leak / assertion error when switching to schemas with custom icons#1836cqjjjzr wants to merge 1 commit intorime:masterfrom
cqjjjzr wants to merge 1 commit intorime:masterfrom
Conversation
…chemas with custom icons Just separate the custom icons and built-in icons, and avoid calling `LoadIconW` on a CIcon with non-null HICON in it.
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash (debug assertion) and potential icon-handle leakage when switching to schemas that use custom status icons, by separating built-in and custom icon storage and ensuring old custom icons are destroyed before reloading.
Changes:
- Introduces dedicated
CIconmembers to hold custom schema icons separately from built-in resource icons. - Replaces the previous “load into the same
CIcon” logic with a helper that destroys any existing handle before attaching a newly loaded icon. - Adds a simple “custom if successfully loaded, otherwise built-in” selection path when painting the status icon.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| WeaselUI/WeaselPanel.h | Adds CIcon members for custom icons to keep them separate from built-in icons. |
| WeaselUI/WeaselPanel.cpp | Implements custom icon loading with explicit destroy/attach and uses a fallback to built-in icons during paint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
在 Debug 模式下如果切换到有自定义图标的方案时会引起 Assertion Error 而崩溃,因为在往一个已经有数据的
CIcon上LoadIconW。这里把内建和自定义图标的
CIcon分开管理了,并确保在已经有HICON != nullptr的CIcon上加载时会先销毁旧的。