Some plugins' icons disappear when going from light to dark mode
-
For some time, I’ve had a weird issue with JsonTools and my other plugins (all developed in C#) where, when I go from light to dark mode, some or all of my icons disappear. To be clear:
- GOOD: If I start in dark mode, all the dark mode icons are visible
- GOOD: If I start in light mode, all the light mode icons are visible
- GOOD: If I switch from dark to light mode, all the dark mode icons change to light mode.
- BAD: If I switch from light to dark mode, only some of the dark mode icons are visible.
The weirdest thing about switching from light to dark mode is that, as shown above, the tab bar with the icons still has the correct number of slots for icons, but every command not before the first unloaded icon will either have no icon (if it was one of the last icons to the right) or will have the wrong icon (as shown here).
This only seems to happen with C# plugins made using this plugin pack or my related plugin pack, so I’m guessing this is somehow related to how C# handles icons, but I have no idea what the issue could be.
- GOOD: If I start in dark mode, all the dark mode icons are visible
-
I could be missing something, but it looks like you’re loading bitmaps from the PNG files in your resource directory (?)
PNGs are not bitmaps. One is a compressed format, the other is not. If you write PNG data into memory that was allocated for a bitmap, you should “expect the unexpected”.
-
I could be missing something, but it looks like you’re loading bitmaps from the PNG files in your resource directory (?)
No, I have
bmp
andico
files in the Resources directory, and those are referenced in theResources.resx
file. They aren’t 32x32 and 16x16, but if their size is the problem, then why do I only have problems when I’m switching from light mode to dark mode and not any other time?EDIT: The PNG files are in the same directory because I take screenshots of a PowerPoint presentation and then use ImageMagick in this batch file to regenerate the
bmp
andico
files whenever I want to change the icons. -
IMO most of the available evidence points to a very subtle bug in Notepad++, and so far nothing (including my own staring at how my icon initialization code compares to the corresponding code in other plugins like this code here) has particularly dissuaded me from this perspective.
FWIW, most of the Notepad++ code manipulating icons on the toolbar seems to be in the
ToolBar::reset(bool create)
method. I’ve tried to step through it in the debugger, but I just don’t have the patience to figure out what the hell is going on. Maybe I’ll take another crack at it tomorrow and figure something out.