Skip to content

Commit 306966b

Browse files
arunjose696HeikoKlare
authored andcommitted
Fix GDI handle leak when clearing MenuItem images
When setting a null image on a MenuItem, the existing bitmap handle was overwritten with 0 without being released, causing a GDI handle leak if the MenuItem previously had an icon. This commit makes sure the handle is always deleted if it was set before.
1 parent a479377 commit 306966b

File tree

1 file changed

+1
-1
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

1 file changed

+1
-1
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,7 @@ private void updateImage () {
807807
info.hbmpItem = OS.HBMMENU_CALLBACK;
808808
} else {
809809
if (OS.IsAppThemed ()) {
810+
if (hBitmap != 0) OS.DeleteObject (hBitmap);
810811
hBitmap = getMenuItemIconBitmapHandle(image);
811812
if ((style & (SWT.CHECK | SWT.RADIO)) != 0 && CUSTOM_SELECTION_IMAGE > 0) {
812813
info.fMask |= OS.MIIM_CHECKMARKS;
@@ -895,7 +896,6 @@ private long getMenuItemIconBitmapHandle(Image image) {
895896
if (image == null) {
896897
return 0;
897898
}
898-
if (hBitmap != 0) OS.DeleteObject (hBitmap);
899899
int zoom = adaptZoomForMenuItem(nativeZoom, image);
900900
return Display.create32bitDIB (image, zoom);
901901
}

0 commit comments

Comments
 (0)