Commit 4bfe7972 authored by Olivier Crête's avatar Olivier Crête Committed by Martin Pitt
Browse files

pygi-property: Lookup property in base classes of non-introspected types

Look for introspection data in the base classes of non-introspected gtypes.
This is necessary to look up introspection data for plugins.

https://bugzilla.gnome.org/show_bug.cgi?id=684058
parent 7aa94cc8
......@@ -54,27 +54,27 @@ _pygi_lookup_property_from_g_type (GType g_type, const gchar *attr_name)
repository = g_irepository_get_default();
info = g_irepository_find_by_gtype (repository, g_type);
if (info == NULL) {
return NULL;
}
if (info != NULL) {
n_infos = g_object_info_get_n_properties ( (GIObjectInfo *) info);
for (i = 0; i < n_infos; i++) {
GIPropertyInfo *property_info;
n_infos = g_object_info_get_n_properties ( (GIObjectInfo *) info);
for (i = 0; i < n_infos; i++) {
GIPropertyInfo *property_info;
property_info = g_object_info_get_property ( (GIObjectInfo *) info, i);
g_assert (info != NULL);
property_info = g_object_info_get_property ( (GIObjectInfo *) info,
i);
g_assert (info != NULL);
if (strcmp (attr_name, g_base_info_get_name (property_info)) == 0) {
g_base_info_unref (info);
return property_info;
if (strcmp (attr_name, g_base_info_get_name (property_info)) == 0) {
g_base_info_unref (info);
return property_info;
}
g_base_info_unref (property_info);
}
g_base_info_unref (property_info);
g_base_info_unref (info);
}
g_base_info_unref (info);
parent = g_type_parent (g_type);
if (parent > 0)
return _pygi_lookup_property_from_g_type (parent, attr_name);
......
......@@ -596,6 +596,18 @@ class TestProperties(unittest.TestCase):
object_.props.gtype = str
self.assertEqual(object_.props.gtype, GObject.TYPE_STRING)
def test_parent_class(self):
class A(Everything.TestObj):
prop1 = GObject.Property(type=int)
a = A()
a.props.int = 20
self.assertEqual(a.props.int, 20)
# test parent property which needs introspection
a.props.list = ("str1", "str2")
self.assertEqual(a.props.list, ["str1", "str2"])
class TestTortureProfile(unittest.TestCase):
def test_torture_profile(self):
......
Supports Markdown
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