From 178aa35e7ecdb884ef3df86bd19fb38322faa176 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Wed, 6 Aug 2014 16:05:06 -0500 Subject: [PATCH] Ensure icon resource stream is closed --- src/mpdnotify.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mpdnotify.py b/src/mpdnotify.py index 2d1dc1a..26e1293 100644 --- a/src/mpdnotify.py +++ b/src/mpdnotify.py @@ -236,12 +236,12 @@ class Notifier(object): def show_status_icon(self): loader = GdkPixbuf.PixbufLoader() - img = pkg_resources.resource_stream('mpdnotify', 'mpd-logo.png') - with contextlib.closing(loader): - for d in iter(lambda: img.read(1), b''): - loader.write(d) - self.icon = Gtk.StatusIcon.new_from_pixbuf(loader.get_pixbuf()) - self.icon.set_tooltip_text('Not connected') + with pkg_resources.resource_stream('mpdnotify', 'mpd-logo.png') as img: + with contextlib.closing(loader): + for d in iter(lambda: img.read(1), b''): + loader.write(d) + self.icon = Gtk.StatusIcon.new_from_pixbuf(loader.get_pixbuf()) + self.icon.set_tooltip_text('Not connected') def stop(self): try: