Skip to content

Fix memory leak / assertion error when switching to schemas with custom icons#1836

Open
cqjjjzr wants to merge 1 commit intorime:masterfrom
cqjjjzr:icon-fix
Open

Fix memory leak / assertion error when switching to schemas with custom icons#1836
cqjjjzr wants to merge 1 commit intorime:masterfrom
cqjjjzr:icon-fix

Conversation

@cqjjjzr
Copy link
Copy Markdown

@cqjjjzr cqjjjzr commented Apr 9, 2026

在 Debug 模式下如果切换到有自定义图标的方案时会引起 Assertion Error 而崩溃,因为在往一个已经有数据的 CIconLoadIconW

这里把内建和自定义图标的 CIcon 分开管理了,并确保在已经有 HICON != nullptrCIcon 上加载时会先销毁旧的。

…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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CIcon members 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.

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