Skip to content

Commit 91c2e3b

Browse files
Changing the logic to destroy temporary handle
1 parent 362a15b commit 91c2e3b

File tree

1 file changed

+18
-10
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+18
-10
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,14 +2079,10 @@ public static Image win32_new(Device device, int type, long handle, int nativeZo
20792079
}
20802080

20812081
private void destroyHandle(int zoom) {
2082-
zoomLevelToImageHandle.entrySet().removeIf(entry -> {
2083-
final Integer zoomKey = entry.getKey();
2084-
if (zoom == zoomKey) {
2085-
destroyHandle(entry.getValue().handle);
2086-
return true;
2087-
}
2088-
return false;
2089-
});
2082+
ImageHandle imageHandle = zoomLevelToImageHandle.remove(zoom);
2083+
if (imageHandle != null) {
2084+
destroyHandle(imageHandle.handle);
2085+
}
20902086
}
20912087

20922088
private abstract class AbstractImageProviderWrapper {
@@ -2123,6 +2119,7 @@ private class ImageFileNameProviderWrapper extends AbstractImageProviderWrapper
21232119
* ImageFileNameProvider to provide file names at various Zoom levels
21242120
*/
21252121
private final ImageFileNameProvider provider;
2122+
private boolean isDestroyed;
21262123
private int width;
21272124
private int height;
21282125
private final static int BASE_ZOOM = 100;
@@ -2183,7 +2180,12 @@ ImageFileNameProviderWrapper createCopy(Image image) {
21832180

21842181
@Override
21852182
boolean isDisposed() {
2186-
return false;
2183+
return this.isDestroyed;
2184+
}
2185+
2186+
@Override
2187+
protected void destroy() {
2188+
this.isDestroyed = true;
21872189
}
21882190
}
21892191

@@ -2195,6 +2197,7 @@ private class ImageDataProviderWrapper extends AbstractImageProviderWrapper {
21952197
private final ImageDataProvider provider;
21962198
private int width;
21972199
private int height;
2200+
private boolean isDestroyed;
21982201
private final static int BASE_ZOOM = 100;
21992202

22002203
ImageDataProviderWrapper(ImageDataProvider provider) {
@@ -2229,7 +2232,12 @@ ImageHandle getImageMetadata(int zoom) {
22292232

22302233
@Override
22312234
boolean isDisposed() {
2232-
return false;
2235+
return this.isDestroyed;
2236+
}
2237+
2238+
@Override
2239+
protected void destroy() {
2240+
this.isDestroyed = true;
22332241
}
22342242

22352243
@Override

0 commit comments

Comments
 (0)