[banshee] [NotificationArea] Properly dispose discarded pixbufs



commit c04a06c282e6471a64124175180fd4a5618cee9c
Author: Chow Loong Jin <hyperair ubuntu com>
Date:   Mon Apr 12 18:58:37 2010 +0200

    [NotificationArea] Properly dispose discarded pixbufs
    
    Any pixbuf returned by LookupScalePixbuf or LookupPixbuf was not
    disposed. We can dispose it immediately, as we only send the filename
    now.
    Also fix a cosmetic code issue.
    
    Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>

 .../NotificationAreaService.cs                     |   21 ++++++++++++-------
 1 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
index 011e596..34b905b 100644
--- a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
+++ b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
@@ -442,20 +442,25 @@ namespace Banshee.NotificationArea
                 current_track.ArtistName, current_track.DisplayArtistName,
                 current_track.AlbumTitle, current_track.DisplayAlbumTitle);
 
-            String image = null;
+            string image = null;
 
             image = is_notification_daemon
                 ? CoverArtSpec.GetPathForSize (current_track.ArtworkId, icon_size)
                 : CoverArtSpec.GetPath (current_track.ArtworkId);
 
             if (!File.Exists (new SafeUri(image))) {
-                // artwork does not exist, try looking up the pixbuf to trigger scaling or conversion
-                if (artwork_manager_service == null ||
-                    (is_notification_daemon &&
-                     artwork_manager_service.LookupScalePixbuf (current_track.ArtworkId, icon_size) == null) ||
-                    (!is_notification_daemon &&
-                     artwork_manager_service.LookupPixbuf (current_track.ArtworkId) == null))
-                    image = "audio-x-generic";
+                if (artwork_manager_service != null) {
+                    // artwork does not exist, try looking up the pixbuf to trigger scaling or conversion
+                    Gdk.Pixbuf tmp_pixbuf = is_notification_daemon
+                        ? artwork_manager_service.LookupScalePixbuf (current_track.ArtworkId, icon_size)
+                        : artwork_manager_service.LookupPixbuf (current_track.ArtworkId);
+
+                    if (tmp_pixbuf == null) {
+                        image = "audio-x-generic";
+                    } else {
+                        tmp_pixbuf.Dispose ();
+                    }
+                }
             }
 
             try {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]