Skip to content

Commit 4bafcb3

Browse files
akoch-yattaHeikoKlare
authored andcommitted
[win32] Move and fix some Image initialization checks
This commit moves some initialization checks related to ImageFileNameProvider into the matching This commit moves some initialization checks related to ImageFileNameProvider into the matching Wrapper implementation. It also fixes when an IllegalArgumentException is thrown by the initialization to conform to the constructor' contract.
1 parent f92ce76 commit 4bafcb3

File tree

1 file changed

+5
-6
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,6 @@ public Image (Device device, String filename) {
521521
}
522522
return null;
523523
});
524-
if (imageProvider.getImageData(100) == null) {
525-
SWT.error(SWT.ERROR_INVALID_ARGUMENT, null,
526-
": [" + filename + "] returns null ImageData at 100% zoom.");
527-
}
528524
init();
529525
this.device.registerResourceWithZoomSupport(this);
530526
}
@@ -562,9 +558,9 @@ public Image(Device device, ImageFileNameProvider imageFileNameProvider) {
562558
super(device);
563559
this.imageProvider = new ImageFileNameProviderWrapper(imageFileNameProvider);
564560
initialNativeZoom = DPIUtil.getNativeDeviceZoom();
565-
if (imageProvider.getImageData(100) == null) {
561+
if (imageFileNameProvider.getImagePath(100) == null) {
566562
SWT.error(SWT.ERROR_INVALID_ARGUMENT, null,
567-
": ImageFileNameProvider [" + imageFileNameProvider + "] returns null ImageData at 100% zoom.");
563+
": ImageFileNameProvider [" + imageFileNameProvider + "] returns null fileName at 100% zoom.");
568564
}
569565
init();
570566
this.device.registerResourceWithZoomSupport(this);
@@ -2221,6 +2217,9 @@ protected Rectangle getBounds(int zoom) {
22212217
private class ImageFileNameProviderWrapper extends BaseImageProviderWrapper<ImageFileNameProvider> {
22222218
ImageFileNameProviderWrapper(ImageFileNameProvider provider) {
22232219
super(provider, ImageFileNameProvider.class);
2220+
// Checks for the contract of the passed provider require
2221+
// checking for valid image data creation
2222+
newImageData(DPIUtil.getDeviceZoom());
22242223
}
22252224

22262225
@Override

0 commit comments

Comments
 (0)