From 1aa34ec9cf4ddd9dab038465fa51a96747c8a488 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Fri, 17 May 2013 07:36:26 +0200 Subject: [PATCH] Always close the pixbufloader. --- manga/reader.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/manga/reader.py b/manga/reader.py index ca8f433..6694ecd 100644 --- a/manga/reader.py +++ b/manga/reader.py @@ -76,18 +76,20 @@ class imgload(future): def value(self): buf = gtk.gdk.PixbufLoader() - with self.page.open() as st: - self.p = 0 - self.st = st - while True: - read = st.read(1024) - if read == "": - break - self.p += len(read) - buf.write(read) - self.progcb() - self.st = None - buf.close() + try: + with self.page.open() as st: + self.p = 0 + self.st = st + while True: + read = st.read(1024) + if read == "": + break + self.p += len(read) + buf.write(read) + self.progcb() + self.st = None + finally: + buf.close() return buf.get_pixbuf() @property -- 2.11.0