Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 317872

Summary: cocoa icon problem
Product: [Eclipse Project] Platform Reporter: Andre Weinand <andre_weinand>
Component: SWTAssignee: Scott Kovatch <skovatch>
Status: RESOLVED FIXED QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: normal    
Priority: P3 CC: skovatch
Version: 3.6   
Target Milestone: 3.7 M2   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
cocoa icon problem
none
cocoa icon problem
none
Fix none

Description Andre Weinand CLA 2010-06-24 14:35:39 EDT
Created attachment 172660 [details]
cocoa icon problem

Eclipse 3.6 Cocoa seems to have problems with certain (SWT?) images.
See attached screenshot.

The images are shown correctly in Carbon.
Comment 1 Andre Weinand CLA 2010-06-24 14:38:14 EDT
Created attachment 172662 [details]
cocoa icon problem
Comment 2 Scott Kovatch CLA 2010-08-23 17:04:57 EDT
Do you have an application that has claimed files of type 'note'? Change some file to have an extension of '.note'. I bet the icon changes to the same one as in the Cocoa screen shot.

I think I have a fix, but I want to check first on how we get into this state.
Comment 3 Andre Weinand CLA 2010-08-23 17:24:18 EDT
I've created a "abc.note" file but its Finder icon is just a blank document icon.
So I'm very sorry that I cannot confirm your hypothesis.
But the problem seems to be a specific problem of my Mac: other Mac users in Zurich do not have this problem.
Comment 4 Scott Kovatch CLA 2010-08-23 17:46:06 EDT
Run this app and see what you get. This is how we are getting the note icon, but I suspect on your system it will show the strange icon and hopefully the owning application.

-------------
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.cocoa.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class NoteIconTest {
	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new GridLayout(1, false));
		NSString fileType = new NSString (OS.NSFileTypeForHFSTypeCode (OS.kAlertNoteIcon));
		System.out.println ("Note icon file type = " + fileType.getString());
		NSImage nsImage = NSWorkspace.sharedWorkspace ().iconForFileType (fileType);
		if (nsImage != null) nsImage.retain();
		Image img = Image.cocoa_new(display, SWT.ICON, nsImage);
		Label label = new Label(shell, SWT.NONE);
		label.setImage(img);

		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}

---------------
Comment 5 Andre Weinand CLA 2010-08-23 18:04:36 EDT
yes, the snippet shows the note icon and prints this to the console:
Note icon file type = 'note'
Comment 6 Scott Kovatch CLA 2010-08-23 18:29:13 EDT
Created attachment 177278 [details]
Fix
Comment 7 Scott Kovatch CLA 2010-08-23 18:30:20 EDT
Used a different IconRef/NSImage combination for retrieving the system icons.

Fixed > 20100823.