From 85b1753a287ce9b57dcbc18382870762b9dd8c90 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Wed, 15 Feb 2012 22:37:36 +0000 Subject: [PATCH] Fix compatibility for Python2.5 and Debian Lenny Recent commit to handle warnings were >=Py2.6 and glib binding is unavailable on Debian Lenny. --- deluge/ui/gtkui/filtertreeview.py | 10 ++++++---- deluge/ui/gtkui/torrentview.py | 9 +++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/deluge/ui/gtkui/filtertreeview.py b/deluge/ui/gtkui/filtertreeview.py index 09f136db1..66012f8bf 100644 --- a/deluge/ui/gtkui/filtertreeview.py +++ b/deluge/ui/gtkui/filtertreeview.py @@ -38,7 +38,6 @@ import gtk import gtk.glade import pkg_resources -import glib import warnings import deluge.component as component @@ -259,9 +258,12 @@ class FilterTreeView(component.Component): count = model.get_value(row, 3) #Supress Warning: g_object_set_qdata: assertion `G_IS_OBJECT (object)' failed - with warnings.catch_warnings(): - warnings.simplefilter("ignore") + original_filters = warnings.filters[:] + warnings.simplefilter("ignore") + try: pix = model.get_value(row, 4) + finally: + warnings.filters = original_filters if pix: self.renderpix.set_property("visible", True) @@ -289,7 +291,7 @@ class FilterTreeView(component.Component): if pix: try: return gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap("%s16.png" % pix)) - except glib.GError as e: + except Exception, e: log.warning(e) return self.get_transparent_pix(16, 16) diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index e324d7699..8d2aa1f08 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtkui/torrentview.py @@ -83,11 +83,16 @@ def cell_data_statusicon(column, cell, model, row, data): """Display text with an icon""" try: icon = ICON_STATE[model.get_value(row, data)] + #Supress Warning: g_object_set_qdata: assertion `G_IS_OBJECT (object)' failed - with warnings.catch_warnings(): - warnings.simplefilter("ignore") + original_filters = warnings.filters[:] + warnings.simplefilter("ignore") + try: if cell.get_property("pixbuf") != icon: cell.set_property("pixbuf", icon) + finally: + warnings.filters = original_filters + except KeyError: pass