diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java index 12a9c521adf..3450118afdc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java @@ -119,7 +119,7 @@ public final class Cursor extends Resource { public Cursor(Device device, int style) { super(device); this.cursorHandleProvider = new StyleCursorHandleProvider(style); - this.handle = this.cursorHandleProvider.createHandle(device, DEFAULT_ZOOM).getHandle(); + this.handle = this.cursorHandleProvider.createHandle(this.device, DEFAULT_ZOOM).getHandle(); init(); this.device.registerResourceWithZoomSupport(this); } @@ -160,7 +160,7 @@ public Cursor(Device device, int style) { public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) { super(device); this.cursorHandleProvider = new ImageDataWithMaskCursorHandleProvider(source, mask, hotspotX, hotspotY); - this.handle = this.cursorHandleProvider.createHandle(device, DEFAULT_ZOOM).getHandle(); + this.handle = this.cursorHandleProvider.createHandle(this.device, DEFAULT_ZOOM).getHandle(); init(); this.device.registerResourceWithZoomSupport(this); } @@ -229,7 +229,7 @@ private static CursorHandle setupCursorFromImageData(ImageData source, ImageData public Cursor(Device device, ImageData source, int hotspotX, int hotspotY) { super(device); this.cursorHandleProvider = new ImageDataCursorHandleProvider(source, hotspotX, hotspotY); - this.handle = this.cursorHandleProvider.createHandle(device, DEFAULT_ZOOM).getHandle(); + this.handle = this.cursorHandleProvider.createHandle(this.device, DEFAULT_ZOOM).getHandle(); init(); this.device.registerResourceWithZoomSupport(this); } @@ -341,7 +341,7 @@ public Cursor(Device device, ImageDataProvider imageDataProvider, int hotspotX, super(device); if (imageDataProvider == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); this.cursorHandleProvider = new ImageDataProviderCursorHandleProvider(imageDataProvider, hotspotX, hotspotY); - this.handle = this.cursorHandleProvider.createHandle(device, DEFAULT_ZOOM).getHandle(); + this.handle = this.cursorHandleProvider.createHandle(this.device, DEFAULT_ZOOM).getHandle(); init(); this.device.registerResourceWithZoomSupport(this); } diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Cursor.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Cursor.java index cb8647a4a85..7c5f40d48a3 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Cursor.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Cursor.java @@ -154,6 +154,8 @@ public void test_ConstructorWithImageDataProvider() { Image sourceImage = new Image(display, 10, 10); Cursor cursor = new Cursor(display, sourceImage::getImageData, 0, 0); cursor.dispose(); + cursor = new Cursor(null, sourceImage::getImageData, 0, 0); + cursor.dispose(); sourceImage.dispose(); assertThrows("No exception thrown when ImageDataProvider is null",