libs-gui icon indicating copy to clipboard operation
libs-gui copied to clipboard

bug: [NSApp setApplicationIconImage:] doesn't set the image

Open iamleeg opened this issue 3 years ago • 2 comments

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:

  1. if you launch with no args, it calls [NSApp setApplicationIconImage:dockImage]. This doesn't do anything, and the app's dock tile remains empty.
  2. if you launch as IconDrawing.app/IconDrawing -UseIconWindow YES, it sets the image in an NSImageView, 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).

iamleeg avatar Mar 31 '21 19:03 iamleeg

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.

iamleeg avatar Apr 07 '21 14:04 iamleeg

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

rmottola avatar Sep 04 '23 22:09 rmottola