Skip to content

Commit 27e19be

Browse files
authored
Merge branch 'eclipse-platform:master' into master
2 parents 822ab7a + a3cc110 commit 27e19be

2 files changed

Lines changed: 18 additions & 29 deletions

File tree

  • bundles
    • org.eclipse.swt.tools/META-INF
    • org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

bundles/org.eclipse.swt.tools/META-INF/MANIFEST.MF

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,5 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0",
1212
org.eclipse.core.resources;bundle-version="3.4.0",
1313
org.eclipse.jdt.core;bundle-version="3.4.0",
1414
org.eclipse.ui;bundle-version="3.4.0",
15-
org.eclipse.jface.text;bundle-version="3.4.0",
16-
org.eclipse.swt.tools.base;bundle-version="3.106.0";visibility:=reexport,
17-
org.eclipse.swt.tools.spies;bundle-version="3.106.0";visibility:=reexport
15+
org.eclipse.jface.text;bundle-version="3.4.0"
1816
Automatic-Module-Name: org.eclipse.swt.tools

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

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
@@ -521,10 +526,6 @@ public Image (Device device, String filename) {
521526
}
522527
return null;
523528
});
524-
if (imageProvider.getImageData(100) == null) {
525-
SWT.error(SWT.ERROR_INVALID_ARGUMENT, null,
526-
": [" + filename + "] returns null ImageData at 100% zoom.");
527-
}
528529
init();
529530
this.device.registerResourceWithZoomSupport(this);
530531
}
@@ -562,9 +563,9 @@ public Image(Device device, ImageFileNameProvider imageFileNameProvider) {
562563
super(device);
563564
this.imageProvider = new ImageFileNameProviderWrapper(imageFileNameProvider);
564565
initialNativeZoom = DPIUtil.getNativeDeviceZoom();
565-
if (imageProvider.getImageData(100) == null) {
566+
if (imageFileNameProvider.getImagePath(100) == null) {
566567
SWT.error(SWT.ERROR_INVALID_ARGUMENT, null,
567-
": ImageFileNameProvider [" + imageFileNameProvider + "] returns null ImageData at 100% zoom.");
568+
": ImageFileNameProvider [" + imageFileNameProvider + "] returns null fileName at 100% zoom.");
568569
}
569570
init();
570571
this.device.registerResourceWithZoomSupport(this);
@@ -1003,7 +1004,7 @@ public static void drawScaled(GC gc, Image original, int width, int height, floa
10031004
void destroy () {
10041005
device.deregisterResourceWithZoomSupport(this);
10051006
if (memGC != null) memGC.dispose();
1006-
this.imageProvider.destroy();
1007+
this.isDestroyed = true;
10071008
destroyHandle();
10081009
memGC = null;
10091010
}
@@ -1229,7 +1230,10 @@ public ImageData getImageData() {
12291230
*/
12301231
public ImageData getImageData (int zoom) {
12311232
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
1232-
return imageProvider.getImageData(zoom);
1233+
if (zoomLevelToImageHandle.containsKey(zoom)) {
1234+
return zoomLevelToImageHandle.get(zoom).getImageData();
1235+
}
1236+
return this.imageProvider.newImageData(zoom);
12331237
}
12341238

12351239

@@ -1766,7 +1770,7 @@ public void internal_dispose_GC (long hDC, GCData data) {
17661770
*/
17671771
@Override
17681772
public boolean isDisposed() {
1769-
return this.imageProvider.isDisposed();
1773+
return !isInitialized || isDestroyed;
17701774
}
17711775

17721776
/**
@@ -1850,17 +1854,9 @@ public static Image win32_new(Device device, int type, long handle, int nativeZo
18501854
}
18511855

18521856
private abstract class AbstractImageProviderWrapper {
1853-
private boolean isDestroyed;
18541857

18551858
protected abstract Rectangle getBounds(int zoom);
18561859

1857-
protected final ImageData getImageData(int zoom) {
1858-
if (zoomLevelToImageHandle.containsKey(zoom)) {
1859-
return zoomLevelToImageHandle.get(zoom).getImageData();
1860-
}
1861-
return newImageData(zoom);
1862-
}
1863-
18641860
abstract ImageData newImageData(int zoom);
18651861

18661862
abstract AbstractImageProviderWrapper createCopy(Image image);
@@ -1892,14 +1888,6 @@ protected final ImageHandle newImageHandle(ImageData data, int zoom) {
18921888
return init(data, zoom);
18931889
}
18941890
}
1895-
1896-
protected boolean isDisposed() {
1897-
return !isInitialized || isDestroyed;
1898-
}
1899-
1900-
protected void destroy() {
1901-
this.isDestroyed = true;
1902-
}
19031891
}
19041892

19051893
private class ExistingImageHandleProviderWrapper extends AbstractImageProviderWrapper {
@@ -1944,7 +1932,7 @@ private abstract class ImageFromImageDataProviderWrapper extends AbstractImagePr
19441932
void initImage() {
19451933
// As the init call configured some Image attributes (e.g. type)
19461934
// it must be called
1947-
getImageData(100);
1935+
newImageData(100);
19481936
}
19491937

19501938
@Override
@@ -2221,6 +2209,9 @@ protected Rectangle getBounds(int zoom) {
22212209
private class ImageFileNameProviderWrapper extends BaseImageProviderWrapper<ImageFileNameProvider> {
22222210
ImageFileNameProviderWrapper(ImageFileNameProvider provider) {
22232211
super(provider, ImageFileNameProvider.class);
2212+
// Checks for the contract of the passed provider require
2213+
// checking for valid image data creation
2214+
newImageData(DPIUtil.getDeviceZoom());
22242215
}
22252216

22262217
@Override

0 commit comments

Comments
 (0)