[pygobject/pygobject-3-10] Fix TypeError when setting drag target_list to None
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/pygobject-3-10] Fix TypeError when setting drag target_list to None
- Date: Mon, 14 Oct 2013 08:07:46 +0000 (UTC)
commit 43ac1f9fd4b1f5132b7fa996da7e307371d11bb1
Author: Nuno Araujo <nuno araujo russo79 com>
Date: Fri Oct 11 18:41:48 2013 +0200
Fix TypeError when setting drag target_list to None
When calling Widget.drag_dest_set_target_list(None) or Widget.drag_source_set_target_list(None)
a "TypeError: 'NoneType' object is not iterable" is thrown.
According to Gtk documentation [1] [2], this shouldn't be the case since client code should be
able to pass NULL in calls made to gtk_drag_dest_set_target_list and
gtk_drag_source_set_target_list.
We now check if the target_list is None and do not try to create a TargetList if it is the case.
[1] https://developer.gnome.org/gtk3/3.10/gtk3-Drag-and-Drop.html#gtk-drag-dest-set-target-list
[2] https://developer.gnome.org/gtk3/3.10/gtk3-Drag-and-Drop.html#gtk-drag-source-set-target-list
https://bugzilla.gnome.org/show_bug.cgi?id=709926
gi/overrides/Gtk.py | 4 ++--
tests/test_overrides_gtk.py | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 5899596..e774c0c 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -73,12 +73,12 @@ class Widget(Gtk.Widget):
return super(Widget, self).render_icon(stock_id, size, detail)
def drag_dest_set_target_list(self, target_list):
- if not isinstance(target_list, Gtk.TargetList):
+ if (target_list is not None) and (not isinstance(target_list, Gtk.TargetList)):
target_list = Gtk.TargetList.new(_construct_target_list(target_list))
super(Widget, self).drag_dest_set_target_list(target_list)
def drag_source_set_target_list(self, target_list):
- if not isinstance(target_list, Gtk.TargetList):
+ if (target_list is not None) and (not isinstance(target_list, Gtk.TargetList)):
target_list = Gtk.TargetList.new(_construct_target_list(target_list))
super(Widget, self).drag_source_set_target_list(target_list)
diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py
index fbe51ec..fd97908 100644
--- a/tests/test_overrides_gtk.py
+++ b/tests/test_overrides_gtk.py
@@ -464,6 +464,7 @@ class TestGtk(unittest.TestCase):
widget.drag_dest_get_track_motion()
widget.drag_dest_set_track_motion(True)
widget.drag_dest_get_target_list()
+ widget.drag_dest_set_target_list(None)
widget.drag_dest_set_target_list(Gtk.TargetList.new([Gtk.TargetEntry.new('test', 0, 0)]))
widget.drag_dest_unset()
@@ -479,6 +480,7 @@ class TestGtk(unittest.TestCase):
widget.drag_source_set_icon_pixbuf(GdkPixbuf.Pixbuf())
widget.drag_source_set_icon_stock("")
widget.drag_source_get_target_list()
+ widget.drag_source_set_target_list(None)
widget.drag_source_set_target_list(Gtk.TargetList.new([Gtk.TargetEntry.new('test', 0, 0)]))
widget.drag_source_unset()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]