After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 555613 - gio.VolumeMonitor segfaults
gio.VolumeMonitor segfaults
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gio
2.15.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2008-10-08 21:07 UTC by John Stowers
Modified: 2009-04-14 21:12 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
make gio.VolumeMonitor() return the singleton object (561 bytes, patch)
2008-10-09 20:11 UTC, Paul Pogonyshev
committed Details | Review
patch (496 bytes, patch)
2008-10-09 20:35 UTC, Gian Mario Tagliaretti
none Details | Review

Description John Stowers 2008-10-08 21:07:02 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?
Comment 1 Gian Mario Tagliaretti 2008-10-08 22:05:27 UTC
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.


Comment 2 Paul Pogonyshev 2008-10-09 20:11:49 UTC
Created attachment 120305 [details] [review]
make gio.VolumeMonitor() return the singleton object

Any objections to this patch?  Alternatively, the override can just raise unconditionally.
Comment 3 Gian Mario Tagliaretti 2008-10-09 20:31:07 UTC
Paul that patch cannot compile without warnings.
Comment 4 Gian Mario Tagliaretti 2008-10-09 20:35:12 UTC
Created attachment 120308 [details] [review]
patch

I would do like the enclosed patch instead
Comment 5 Paul Pogonyshev 2008-10-10 19:41:07 UTC
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.
Comment 6 Gustavo Carneiro 2008-10-11 10:32:43 UTC
There's prior art: gconf.Client() in Python maps to gconf_client_get_default() in C.
Comment 7 Gian Mario Tagliaretti 2008-10-11 10:38:26 UTC
(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.
Comment 8 Paul Pogonyshev 2008-10-11 11:47:12 UTC
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.
Comment 9 Paul Pogonyshev 2008-12-06 19:55:39 UTC
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.
Comment 10 Gian Mario Tagliaretti 2009-02-10 22:44:30 UTC
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.
Comment 11 Paul Pogonyshev 2009-02-15 22:51:24 UTC
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).
Comment 12 Gian Mario Tagliaretti 2009-02-16 22:31:33 UTC
Paul, I'll let you decide, I'm fine with both solutions.
Comment 13 Paul Pogonyshev 2009-04-14 21:12:48 UTC
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.