Skip to content

Commit 20d18aa

Browse files
ShahzaibIbrahimHeikoKlare
authored andcommitted
Initialization handles without creating a Cursor instance
In win32_getHandle, a new cursor instance is created to retrieve the OS handle. With this change, we are able to safely retrieve the handle without creating a cursor instance.
1 parent df3188c commit 20d18aa

File tree

1 file changed

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

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,12 @@ public static Long win32_getHandle (Cursor cursor, int zoom) {
444444
source = DPIUtil.scaleImageData(cursor.device, cursor.source, zoom, DEFAULT_ZOOM);
445445
}
446446
if (cursor.isIcon) {
447-
Cursor newCursor = new Cursor(cursor.device, source, Win32DPIUtils.pointToPixel(cursor.hotspotX, zoom), Win32DPIUtils.pointToPixel(cursor.hotspotY, zoom));
448-
cursor.setHandleForZoomLevel(newCursor.handle, zoom);
447+
long handle = setupCursorFromImageData(cursor.getDevice(), source, Win32DPIUtils.pointToPixel(cursor.hotspotX, zoom), Win32DPIUtils.pointToPixel(cursor.hotspotY, zoom));
448+
cursor.setHandleForZoomLevel(handle, zoom);
449449
} else {
450-
ImageData mask = DPIUtil.scaleImageData(cursor.device, cursor.mask, zoom, DEFAULT_ZOOM);
451-
Cursor newCursor = new Cursor(cursor.device, source, mask, Win32DPIUtils.pointToPixel(cursor.hotspotX, zoom), Win32DPIUtils.pointToPixel(cursor.hotspotY, zoom));
452-
cursor.setHandleForZoomLevel(newCursor.handle, zoom);
450+
ImageData mask = DPIUtil.scaleImageData(cursor.getDevice(), cursor.mask, zoom, DEFAULT_ZOOM);
451+
long handle = setupCursorFromImageData(source, mask, Win32DPIUtils.pointToPixel(cursor.hotspotX, zoom), Win32DPIUtils.pointToPixel(cursor.hotspotY, zoom));
452+
cursor.setHandleForZoomLevel(handle, zoom);
453453
}
454454
}
455455
return cursor.zoomLevelToHandle.get(zoom);

0 commit comments

Comments
 (0)