src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp

Print this page

        

@@ -91,10 +91,16 @@
 AwtTrayIcon::~AwtTrayIcon() {
 }
 
 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) {
         AwtTrayIcon::DestroyMessageWindow();
     }