GNOME Bugzilla – Bug 688249
Accessing style context directly from constructor results in a segmentation fault
Last modified: 2012-11-19 06:51:54 UTC
When I run the following code, I get segmentation fault. <code> >>> from gi.repository import Gtk >>> Gtk.TreeView().get_style_context().get_color(Gtk.StateFlags.INSENSITIVE) (.:11732): Gtk-CRITICAL **: gtk_style_context_get_property: assertion `priv->widget != NULL || priv->widget_path != NULL' failed /usr/lib/python3/dist-packages/gi/types.py:47: Warning: /build/buildd/glib2.0-2.34.0/./gobject/gtype.c:4204: type id `0' is invalid return info.invoke(*args, **kwargs) /usr/lib/python3/dist-packages/gi/types.py:47: Warning: can't peek value table for type `<invalid>' which is not currently referenced return info.invoke(*args, **kwargs) Segmentation fault </code> As I found out on #python channel that I should split the constructor and getter in the following way: <code> >>> from gi.repository import Gtk >>> tv = Gtk.TreeView() >>> tv.get_style_context().get_color(Gtk.StateFlags.INSENSITIVE) <Gdk.Color(red=0.585613, green=0.567059, blue=0.548504, alpha=1.000000)> </code> It would be nicer to raise a python exception instead of a segfault.
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find. *** This bug has been marked as a duplicate of bug 678607 ***