1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

Bug 243907 - AbstractCPropertyTab#dispose() never called

- AbstractPage leaks Tab icon SWT Images
    - AbstractCPropertyTab uses reflection for setGrayed API
This commit is contained in:
James Blackburn 2009-10-20 16:40:30 +00:00
parent 353d1d0875
commit ae5e0a74f3
2 changed files with 32 additions and 17 deletions

View file

@ -8,10 +8,10 @@
* Contributors:
* Intel Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
* James Blackburn (Broadcom Corp.)
*******************************************************************************/
package org.eclipse.cdt.ui.newui;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.eclipse.core.resources.IContainer;
@ -533,6 +533,7 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
if (canBeVisible()) configChanged((ICResourceDescription)data);
break;
case ICPropertyTab.DISPOSE:
dispose();
break;
case ICPropertyTab.VISIBLE:
if (canBeVisible())
@ -607,16 +608,11 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
*
* @param b
* @param value
* @deprecated call {@link Button#setGrayed(boolean)} instead
*/
@Deprecated
public static void setGrayed(Button b, boolean value) {
// TODO: uncomment before M5
// b.setGrayed(value);
if (GRAY_METHOD != null)
try {
GRAY_METHOD.invoke(b, new Object[] { new Boolean(value) });
}
catch (InvocationTargetException e) {}
catch (IllegalAccessException e) {}
b.setGrayed(value);
}
/**

View file

@ -10,6 +10,7 @@
* Markus Schorn (Wind River Systems)
* Andrew Gvozdev
* QNX Software Systems - [271628] NPE in configs for project that failed to convert
* James Blackburn (Broadcom Corp.)
*******************************************************************************/
package org.eclipse.cdt.ui.newui;
@ -20,8 +21,10 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@ -145,6 +148,8 @@ implements
private static final String PREF_ASK_REINDEX = "askReindex"; //$NON-NLS-1$
private Map<URL, Image> loadedIcons = new HashMap<URL, Image>();
private final Image IMG_WARN = CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_WARNING);
/*
* Dialog widgets
@ -961,7 +966,13 @@ implements
@Override
public void dispose() {
if (displayedConfig) forEach(ICPropertyTab.DISPOSE);
// Dispose the tabs
if (displayedConfig)
forEach(ICPropertyTab.DISPOSE);
// Dispose any loaded images
for (Image img : loadedIcons.values())
img.dispose();
loadedIcons.clear();
if (!isNewOpening)
handleResize(false); // save page size
@ -1093,14 +1104,22 @@ implements
private Image getIcon(IConfigurationElement config) {
ImageDescriptor idesc = null;
URL url = null;
try {
String iconName = config.getAttribute(IMAGE_NAME);
if (iconName != null) {
URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getEntry("/"); //$NON-NLS-1$
idesc = ImageDescriptor.createFromURL(new URL(pluginInstallUrl, iconName));
url = new URL(pluginInstallUrl, iconName);
if (loadedIcons.containsKey(url))
return loadedIcons.get(url);
idesc = ImageDescriptor.createFromURL(url);
}
} catch (MalformedURLException exception) {}
return (idesc == null) ? null : idesc.createImage();
if (idesc == null)
return null;
Image img = idesc.createImage();
loadedIcons.put(url, img);
return img;
}
public void informAll(int code, Object data) {