Commit 19c1a2df authored by Simon Feltman's avatar Simon Feltman
Browse files

Change boxed type checking in marshaling to use __gtype__ attribute

Replace usage of pyg_boxed_check(pyboxed) with g_type_is_a and
pyg_type_from_object. This has the effect of using the __gtype__
attribute stashed on object class instead of the PyGBoxed
internally held gtype. This fixes type descrepencies for objects
marshaled into overridden signal class closures and passed back
to functions taking an alias their type.
parent dab0c09f
......@@ -1827,7 +1827,13 @@ _pygi_marshal_from_py_interface_struct (PyObject *py_arg,
if (g_type_is_a (g_type, G_TYPE_BOXED)) {
if (pyg_boxed_check (py_arg, g_type)) {
/* Use pyg_type_from_object to pull the stashed __gtype__ attribute
* off of the input argument instead of checking PyGBoxed.gtype
* with pyg_boxed_check. This is needed to work around type discrepancies
* in cases with aliased (typedef) types. e.g. GtkAllocation, GdkRectangle.
* See: https://bugzilla.gnomethere are .org/show_bug.cgi?id=707140
if (g_type_is_a (pyg_type_from_object (py_arg), g_type)) {
arg->v_pointer = pyg_boxed_get (py_arg, void);
if (transfer == GI_TRANSFER_EVERYTHING) {
arg->v_pointer = g_boxed_copy (g_type, arg->v_pointer);
......@@ -589,6 +589,40 @@ class TestGtk(unittest.TestCase):
@unittest.skipUnless(Gtk, 'Gtk not available')
class TestSignals(unittest.TestCase):
class WindowWithSizeAllocOverride(Gtk.ScrolledWindow):
__gsignals__ = {'size-allocate': 'override'}
def __init__(self):
self._alloc_called = False
self._alloc_value = None
self._alloc_error = None
def do_size_allocate(self, alloc):
self._alloc_called = True
self._alloc_value = alloc
Gtk.ScrolledWindow.do_size_allocate(self, alloc)
except Exception as e:
self._alloc_error = e
def test_class_closure_override_with_aliased_type(self):
win = self.WindowWithSizeAllocOverride()
rect = Gdk.Rectangle()
rect.width = 100
rect.height = 100
with realized(win):
self.assertIsInstance(win._alloc_value, Gdk.Rectangle)
self.assertTrue(win._alloc_error is None, win._alloc_error)
@unittest.skipUnless(Gtk, 'Gtk not available')
class TestBuilder(unittest.TestCase):
class SignalTest(GObject.GObject):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment