Re: [Gtk-osx-users] Segmentation fault accessing widget props

On Nov 30, 2010, at 5:14 PM, Richard Procter wrote:

> Hi everyone, 
> I've been looking into why my app segfaults with the latest GTK/PyGTK binaries and have whittled it down to this minimal fragment: 
> import gtk
> w = gtk.Window() 
> w.props.visible 
> This isn't limited to the gtk.Window's visible property: accessing the label property of a gtk.MenuItem breaks just as well.
> Replacing the last line with w.get_property('visible') eliminates the fault.
> I've reproduced this over a couple of builds on different machines but it seems so basic that I'd appreciate it if someone could confirm it for me. 
> Details on versions below. 

That's a new "feature" of Gtk and GLib. You aren't allowed to access properties directly any more, you have to use the accessor functions. If you look in the C source code, you'll see GSEAL all over the place. It's the "we can write OO code in C, yes we can!" version of the private variables in real OO languages. (Yes, that's a slam at Python, because van Rossum doesn't believe in data hiding. He's wrong and Stroustroup's right.)

It is a bit rude of PyGtk to segfault rather than to fail gracefully, but that's not a gtk-osx problem. Go bug them.

John Ralls

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]