GNOME Bugzilla – Bug 555613
gio.VolumeMonitor segfaults
Last modified: 2009-04-14 21:12:48 UTC
Hi, Anything I do with gio.VolumeMonitor() causes it to segfault. import gio v = gio.VolumeMonitor() print v.get_volumes() *BOOM* Has this been wrapped correctly or this this an Ubuntu bug?
Well the bug is that we should avoid the constructor gio.VolumeMonitor() to be called, the right way is to use gio.volume_monitor_get() and use the returned object.
Created attachment 120305 [details] [review] make gio.VolumeMonitor() return the singleton object Any objections to this patch? Alternatively, the override can just raise unconditionally.
Paul that patch cannot compile without warnings.
Created attachment 120308 [details] [review] patch I would do like the enclosed patch instead
Right, I missed that but fixing return type will do it. I think there were some precedents for constructor just returning type singleton object, no (don't remember exact class)? Also, this is quite normal for Python.
There's prior art: gconf.Client() in Python maps to gconf_client_get_default() in C.
(In reply to comment #5) > Right, I missed that but fixing return type will do it. I think there were > some precedents for constructor just returning type singleton object, no (don't > remember exact class)? Also, this is quite normal for Python. > Absolutely fine with me, returning the default VolumeMonitor makes sense indeed.
One unfortunate thing is that current "stable" version released with GNOME doesn't allow that. And if we make gio.VolumeMonitor() return the singleton now, developers can become dependent on this, while it will crash with some GNOME installations.
I applied Gian's patch in pygobject-2-16 branch (not a new feature). Not closing, since we still should decide what to do for 2.17/21.8.
Paul, Gustavo, what about avoiding to use the constructor also in 2.17/2.18? we had no other complaints on this one, I'm afraid that returning the singleton could (?) create only problems at this point.
The only problem I see is that some developers will use it and get user complains that their programs trigger the TypeError with older PyGIO. Still think it is worth it, but only if done this release (because 2.16 is so buggy sane developers should depend on 2.18 when it's out anyway).
Paul, I'll let you decide, I'm fine with both solutions.
I committed my patch, after fixing a compilation warning and function signature. So, in 2.18 gio.VolumeMonitor() will be legal and will always return the singleton object.