@@ -98,6 +98,11 @@ public final class Image extends Resource implements Drawable {
98
98
*/
99
99
private boolean isInitialized ;
100
100
101
+ /**
102
+ * this field is used to mark destroyed images
103
+ */
104
+ private boolean isDestroyed ;
105
+
101
106
/**
102
107
* specifies the transparent pixel
103
108
*/
@@ -999,7 +1004,7 @@ public static void drawScaled(GC gc, Image original, int width, int height, floa
999
1004
void destroy () {
1000
1005
device .deregisterResourceWithZoomSupport (this );
1001
1006
if (memGC != null ) memGC .dispose ();
1002
- this .imageProvider . destroy () ;
1007
+ this .isDestroyed = true ;
1003
1008
destroyHandle ();
1004
1009
memGC = null ;
1005
1010
}
@@ -1225,7 +1230,10 @@ public ImageData getImageData() {
1225
1230
*/
1226
1231
public ImageData getImageData (int zoom ) {
1227
1232
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 );
1229
1237
}
1230
1238
1231
1239
@@ -1762,7 +1770,7 @@ public void internal_dispose_GC (long hDC, GCData data) {
1762
1770
*/
1763
1771
@ Override
1764
1772
public boolean isDisposed () {
1765
- return this . imageProvider . isDisposed () ;
1773
+ return ! isInitialized || isDestroyed ;
1766
1774
}
1767
1775
1768
1776
/**
@@ -1846,17 +1854,9 @@ public static Image win32_new(Device device, int type, long handle, int nativeZo
1846
1854
}
1847
1855
1848
1856
private abstract class AbstractImageProviderWrapper {
1849
- private boolean isDestroyed ;
1850
1857
1851
1858
protected abstract Rectangle getBounds (int zoom );
1852
1859
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
-
1860
1860
abstract ImageData newImageData (int zoom );
1861
1861
1862
1862
abstract AbstractImageProviderWrapper createCopy (Image image );
@@ -1888,14 +1888,6 @@ protected final ImageHandle newImageHandle(ImageData data, int zoom) {
1888
1888
return init (data , zoom );
1889
1889
}
1890
1890
}
1891
-
1892
- protected boolean isDisposed () {
1893
- return !isInitialized || isDestroyed ;
1894
- }
1895
-
1896
- protected void destroy () {
1897
- this .isDestroyed = true ;
1898
- }
1899
1891
}
1900
1892
1901
1893
private class ExistingImageHandleProviderWrapper extends AbstractImageProviderWrapper {
@@ -1940,7 +1932,7 @@ private abstract class ImageFromImageDataProviderWrapper extends AbstractImagePr
1940
1932
void initImage () {
1941
1933
// As the init call configured some Image attributes (e.g. type)
1942
1934
// it must be called
1943
- getImageData (100 );
1935
+ newImageData (100 );
1944
1936
}
1945
1937
1946
1938
@ Override
0 commit comments