Skip to content

Commit 97ca656

Browse files
committed
[Win32] Remove buggy icon retrieval from file extensions #715
Under certain conditions, program icons loaded on Windows via GDI+ have empty mask data, even though the original icon has proper mask data. As a result, these icons are printed with a black instead of a transparent background. This only happens when retrieving icons via the program's file extension but works properly when using the (also available) full icon path. With this change, the shortcut functionality retrieving an icon from a program's file extension is removed, so that the icon is always retrieved from its full path. This fixes the issue with missing mask data and reduces code. Fixes #715
1 parent 771ec8c commit 97ca656

File tree

1 file changed

+2
-18
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program

1 file changed

+2
-18
lines changed

bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public final class Program {
3333
String name;
3434
String command;
3535
String iconName;
36-
String extension;
3736
static final String [] ARGUMENTS = new String [] {"%1", "%l", "%L"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
3837

3938
/**
@@ -100,7 +99,6 @@ public static Program findProgram (String extension) {
10099
program.name = name;
101100
program.command = command;
102101
program.iconName = iconName;
103-
program.extension = extension;
104102
}
105103
return program;
106104
}
@@ -182,7 +180,7 @@ static String getKeyValue (String string, boolean expand) {
182180
return result;
183181
}
184182

185-
static Program getProgram (String key, String extension) {
183+
static Program getProgram (String key) {
186184

187185
/* Name */
188186
String name = getKeyValue (key, false);
@@ -208,7 +206,6 @@ static Program getProgram (String key, String extension) {
208206
program.name = name;
209207
program.command = command;
210208
program.iconName = iconName;
211-
program.extension = extension;
212209
return program;
213210
}
214211

@@ -234,7 +231,7 @@ static Program getProgram (String key, String extension) {
234231
//map paths to programs in parallel which takes now ~ 4/5 of time:
235232
ConcurrentHashMap<String, Program> programs = new ConcurrentHashMap<>(paths.size());
236233
paths.stream().parallel().forEach(path -> {
237-
Program program = getProgram(path, null); // getProgram takes most time
234+
Program program = getProgram(path); // getProgram takes most time
238235
if (program != null) {
239236
programs.put(path, program);
240237
}
@@ -361,19 +358,6 @@ public boolean execute (String fileName) {
361358
* @return the image data for the program, may be null
362359
*/
363360
public ImageData getImageData () {
364-
if (extension != null) {
365-
SHFILEINFO shfi = new SHFILEINFO ();
366-
int flags = OS.SHGFI_ICON | OS.SHGFI_SMALLICON | OS.SHGFI_USEFILEATTRIBUTES;
367-
TCHAR pszPath = new TCHAR (0, extension, true);
368-
OS.SHGetFileInfo (pszPath.chars, OS.FILE_ATTRIBUTE_NORMAL, shfi, SHFILEINFO.sizeof, flags);
369-
if (shfi.hIcon != 0) {
370-
Image image = Image.win32_new (null, SWT.ICON, shfi.hIcon);
371-
/* Fetch the ImageData at 100% zoom and return */
372-
ImageData imageData = image.getImageData ();
373-
image.dispose ();
374-
return imageData;
375-
}
376-
}
377361
int nIconIndex = 0;
378362
String fileName = iconName;
379363
int index = iconName.indexOf (',');

0 commit comments

Comments
 (0)