@@ -98,6 +98,11 @@ public final class Image extends Resource implements Drawable {
9898 */
9999 private boolean isInitialized ;
100100
101+ /**
102+ * this field is used to mark destroyed images
103+ */
104+ private boolean isDestroyed ;
105+
101106 /**
102107 * specifies the transparent pixel
103108 */
@@ -999,7 +1004,7 @@ public static void drawScaled(GC gc, Image original, int width, int height, floa
9991004void destroy () {
10001005 device .deregisterResourceWithZoomSupport (this );
10011006 if (memGC != null ) memGC .dispose ();
1002- this .imageProvider . destroy () ;
1007+ this .isDestroyed = true ;
10031008 destroyHandle ();
10041009 memGC = null ;
10051010}
@@ -1225,7 +1230,10 @@ public ImageData getImageData() {
12251230 */
12261231public ImageData getImageData (int zoom ) {
12271232 if (isDisposed ()) SWT .error (SWT .ERROR_GRAPHIC_DISPOSED );
1228- return imageProvider .getImageData (zoom );
1233+ if (zoomLevelToImageHandle .containsKey (zoom )) {
1234+ return zoomLevelToImageHandle .get (zoom ).getImageData ();
1235+ }
1236+ return this .imageProvider .newImageData (zoom );
12291237}
12301238
12311239
@@ -1762,7 +1770,7 @@ public void internal_dispose_GC (long hDC, GCData data) {
17621770 */
17631771@ Override
17641772public boolean isDisposed () {
1765- return this . imageProvider . isDisposed () ;
1773+ return ! isInitialized || isDestroyed ;
17661774}
17671775
17681776/**
@@ -1846,17 +1854,9 @@ public static Image win32_new(Device device, int type, long handle, int nativeZo
18461854}
18471855
18481856private abstract class AbstractImageProviderWrapper {
1849- private boolean isDestroyed ;
18501857
18511858 protected abstract Rectangle getBounds (int zoom );
18521859
1853- protected final ImageData getImageData (int zoom ) {
1854- if (zoomLevelToImageHandle .containsKey (zoom )) {
1855- return zoomLevelToImageHandle .get (zoom ).getImageData ();
1856- }
1857- return newImageData (zoom );
1858- }
1859-
18601860 abstract ImageData newImageData (int zoom );
18611861
18621862 abstract AbstractImageProviderWrapper createCopy (Image image );
@@ -1888,14 +1888,6 @@ protected final ImageHandle newImageHandle(ImageData data, int zoom) {
18881888 return init (data , zoom );
18891889 }
18901890 }
1891-
1892- protected boolean isDisposed () {
1893- return !isInitialized || isDestroyed ;
1894- }
1895-
1896- protected void destroy () {
1897- this .isDestroyed = true ;
1898- }
18991891}
19001892
19011893private class ExistingImageHandleProviderWrapper extends AbstractImageProviderWrapper {
@@ -1940,7 +1932,7 @@ private abstract class ImageFromImageDataProviderWrapper extends AbstractImagePr
19401932 void initImage () {
19411933 // As the init call configured some Image attributes (e.g. type)
19421934 // it must be called
1943- getImageData (100 );
1935+ newImageData (100 );
19441936 }
19451937
19461938 @ Override
0 commit comments