GNOME Bugzilla – Bug 689277
TreeModelRow does not consider do_get_value implementation for a custom model.
Last modified: 2018-01-10 20:20:56 UTC
Having a custom model that inherits Gtk.TreeModel and implements do_get_value, calling row[model_index] I get this traceback: Traceback (most recent call last):
+ Trace 231240
if row[self._model_column_index] is not None:
return self.model.get_value(self.iter, key)
return info.invoke(*args, **kwargs)
I see pygobject has an override [1] which is calling get_value in the model. So replacing my code like this is the same: - if row[self._model_column_index] is not None: - nick, xo_color = row[self._model_column_index] + if row.model.get_value(row.iter, self._model_column_index) is not None: + nick, xo_color = row.model.get_value(row.iter, self._model_column_index) Now if I rename get_value by do_get_value, I get the expected result. - if row[self._model_column_index] is not None: - nick, xo_color = row[self._model_column_index] + if row.model.do_get_value(row.iter, self._model_column_index) is not None: + nick, xo_color = row.model.do_get_value(row.iter, self._model_column_index) [1] http://git.gnome.org/browse/pygobject/tree/gi/overrides/Gtk.py#n1132
This was seen in the Sugar learning platform, the ticket is http://bugs.sugarlabs.org/ticket/3888 .
Created attachment 230270 [details] TestCase
The issue is when do_get_value returns a tuple like in our code here [1]. The attached testcase shows that only the first element of the tuple is returned. [1] http://git.sugarlabs.org/sugar/mainline/blobs/master/src/jarabe/journal/listmodel.py#line197
Confirmed. A work around is to return the tuple as a GValue: return GObject.Value(GObject.TYPE_PYOBJECT, (len(director), director)) This is most likely confusion in how return/out arg marshaling works.
A cleaner workaround is to return a list: return [len(director), director] The problem is return/out arg marshaling assumes a tuple type means multiple return values: https://git.gnome.org/browse/pygobject/tree/gi/pygi-closure.c?id=3.9.91#n459 We need get the count of expected return/out values and if it is greater than one use a sequence check and pull the items out (also give an error if we expect more than one out values and we don't have a sequence).
Marking as depending on bug 727004 since the patches their will either fix this or move code around where this should be fixed.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/39.