libs-gui
libs-gui copied to clipboard
bug: [NSApp setApplicationIconImage:] doesn't set the image
Environment: freebsd 13, windowmaker, gnustep-gui from git master, clang 11.0.1
Repro project available. This project draws a red square into its dock icon in two ways:
- if you launch with no args, it calls
[NSApp setApplicationIconImage:dockImage]
. This doesn't do anything, and the app's dock tile remains empty. - if you launch as
IconDrawing.app/IconDrawing -UseIconWindow YES
, it sets the image in anNSImageView
, and adds that as a subview to[[NSApp iconWindow] contentView]
. This does work correctly, and draws the red square in the dock icon.
I believe that the first method would be expected by Cocoa developers as it's documented as supported (so is NSDockTile
, which GNUstep doesn't yet have).
Josh Freeman sent me some info that helped narrow this issue down.
-[NSApplication setApplicationIconImage:]
copies its image, and -[NSImage copyWithZone:]
deliberately discards cached image reps. In the case where the image was drawn with the Cocoa drawing APIs, the only rep is a cached rep so the image copy has no reps and doesn't draw anything.
There's a workaround available, which is to ask the image for its -TIFFRepresentation
(which can be discarded) which causes the image to generate a bitmap image rep, and then the copy has a rep to draw. This workaround is only needed on GNUstep, not on Mac.
There was work on seApplicationImage and related views.
Could this bug be related or even duplicated of this? https://github.com/gnustep/libs-gui/issues/187