8155001: SystemTray.remove() leaks GDI Objects in Windows
authordmarkov
Fri, 13 May 2016 12:44:53 +0300
changeset 38416 dd0b515bc286
parent 38415 acea5f7d354b
child 38417 07152c7004b0
child 38970 aabcf4406038
8155001: SystemTray.remove() leaks GDI Objects in Windows Reviewed-by: serb, alexp
jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp	Fri May 13 11:31:05 2016 +0300
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp	Fri May 13 12:44:53 2016 +0300
@@ -93,6 +93,12 @@
 
 void AwtTrayIcon::Dispose() {
     SendTrayMessage(NIM_DELETE);
+
+    // Destroy the icon to avoid leak of GDI objects
+    if (m_nid.hIcon != NULL) {
+        ::DestroyIcon(m_nid.hIcon);
+    }
+
     UnlinkObjects();
 
     if (--sm_instCount == 0) {