]> Pileus Git - ~andy/gtk/commitdiff
Don't leak HICONs on Win32. (#364868, Hiroyuki Yamamoto)
authorTor Lillqvist <tml@novell.com>
Thu, 28 Dec 2006 16:50:35 +0000 (16:50 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Thu, 28 Dec 2006 16:50:35 +0000 (16:50 +0000)
2006-12-28  Tor Lillqvist  <tml@novell.com>

* gtk/gtkstatusicon.c (gtk_status_icon_finalize)
(gtk_status_icon_update_image): Don't leak HICONs on
Win32. (#364868, Hiroyuki Yamamoto)

ChangeLog
gtk/gtkstatusicon.c

index d66beb1dda700211a0fc53b4e4253c50edc26180..3fa6df9c25c8882287358e7cbd9ef843be328727 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-28  Tor Lillqvist  <tml@novell.com>
+
+       * gtk/gtkstatusicon.c (gtk_status_icon_finalize)
+       (gtk_status_icon_update_image): Don't leak HICONs on
+       Win32. (#364868, Hiroyuki Yamamoto)
+
 2006-12-28  Carlos Garnacho  <carlosg@gnome.org>
 
        Make GtkNotebook able to drop detached tabs anywhere. Bug #360225.
index 09a73d862d8a793d842a8df44a319425d054a486..44d3798e59ae3907a2600e9fad2208766db18d6d 100755 (executable)
@@ -566,6 +566,8 @@ gtk_status_icon_finalize (GObject *object)
 #ifdef GDK_WINDOWING_WIN32
   if (priv->nid.hWnd != NULL && priv->visible)
     Shell_NotifyIconW (NIM_DELETE, &priv->nid);
+  if (priv->nid.hIcon)
+    DestroyIcon (priv->nid.hIcon);
 
   gtk_widget_destroy (priv->dummy_widget);
 #endif
@@ -892,6 +894,9 @@ static void
 gtk_status_icon_update_image (GtkStatusIcon *status_icon)
 {
   GtkStatusIconPrivate *priv = status_icon->priv;
+#ifdef GDK_WINDOWING_WIN32
+  HICON prev_hicon;
+#endif
 
   if (priv->blink_off)
     {
@@ -900,11 +905,14 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon)
                                 gtk_status_icon_blank_icon (status_icon));
 #endif
 #ifdef GDK_WINDOWING_WIN32
+      prev_hicon = priv->nid.hIcon;
       priv->nid.hIcon = gdk_win32_pixbuf_to_hicon_libgtk_only (gtk_status_icon_blank_icon (status_icon));
       priv->nid.uFlags |= NIF_ICON;
       if (priv->nid.hWnd != NULL && priv->visible)
        if (!Shell_NotifyIconW (NIM_MODIFY, &priv->nid))
          g_warning ("%s:%d:Shell_NotifyIcon(NIM_MODIFY) failed", __FILE__, __LINE__-1);
+      if (prev_hicon)
+       DestroyIcon (prev_hicon);
 #endif
 #ifdef GDK_WINDOWING_QUARTZ
       QUARTZ_POOL_ALLOC;
@@ -946,11 +954,14 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon)
            gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), scaled);
 #endif
 #ifdef GDK_WINDOWING_WIN32
+           prev_hicon = priv->nid.hIcon;
            priv->nid.hIcon = gdk_win32_pixbuf_to_hicon_libgtk_only (scaled);
            priv->nid.uFlags |= NIF_ICON;
            if (priv->nid.hWnd != NULL && priv->visible)
              if (!Shell_NotifyIconW (NIM_MODIFY, &priv->nid))
                  g_warning ("%s:%d:Shell_NotifyIcon(NIM_MODIFY) failed", __FILE__, __LINE__-1);
+           if (prev_hicon)
+             DestroyIcon (prev_hicon);
 #endif
 #ifdef GDK_WINDOWING_QUARTZ
       QUARTZ_POOL_ALLOC;
@@ -993,11 +1004,15 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon)
                                    priv->image_data.stock_id,
                                    GTK_ICON_SIZE_SMALL_TOOLBAR,
                                    NULL);
+
+         prev_hicon = priv->nid.hIcon;
          priv->nid.hIcon = gdk_win32_pixbuf_to_hicon_libgtk_only (pixbuf);
          priv->nid.uFlags |= NIF_ICON;
          if (priv->nid.hWnd != NULL && priv->visible)
            if (!Shell_NotifyIconW (NIM_MODIFY, &priv->nid))
              g_warning ("%s:%d:Shell_NotifyIcon(NIM_MODIFY) failed", __FILE__, __LINE__-1);
+         if (prev_hicon)
+           DestroyIcon (prev_hicon);
          g_object_unref (pixbuf);
        }
 #endif
@@ -1034,11 +1049,14 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon)
                                      priv->size,
                                      0, NULL);
          
+         prev_hicon = priv->nid.hIcon;
          priv->nid.hIcon = gdk_win32_pixbuf_to_hicon_libgtk_only (pixbuf);
          priv->nid.uFlags |= NIF_ICON;
          if (priv->nid.hWnd != NULL && priv->visible)
            if (!Shell_NotifyIconW (NIM_MODIFY, &priv->nid))
              g_warning ("%s:%d:Shell_NotifyIcon(NIM_MODIFY) failed", __FILE__, __LINE__-1);
+         if (prev_hicon)
+           DestroyIcon (prev_hicon);
          g_object_unref (pixbuf);
        }
 #endif