From 6115dfc41945c8a7119f9ccdf95c9772a4d5f0a4 Mon Sep 17 00:00:00 2001 From: Amartya Parijat Date: Tue, 17 Dec 2024 16:36:26 +0100 Subject: [PATCH] Add exception to setImageMetadataForHandle This commit adds a check for imageMetadata for handle in case, there already exists an entry in the zoomLeveltoImageHandle map for a zoom level and it must throw an exception in that case. contributes to #62 and #127 --- .../Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java index bb55941f0ce..a512f791368 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java @@ -1788,9 +1788,12 @@ else if (i.alphaData != null) { } private void setImageMetadataForHandle(ImageHandle imageMetadata, Integer zoom) { - if (zoom != null && !zoomLevelToImageHandle.containsKey(zoom)) { - zoomLevelToImageHandle.put(zoom, imageMetadata); + if (zoom == null) + return; + if (zoomLevelToImageHandle.containsKey(zoom)) { + SWT.error(SWT.ERROR_ITEM_NOT_ADDED); } + zoomLevelToImageHandle.put(zoom, imageMetadata); } static long [] init(Device device, Image image, ImageData source, ImageData mask, Integer zoom) {