GNOME Bugzilla – Bug 151463
GnomeVFSVolumeMonitor should not be refcounted
Last modified: 2008-09-06 19:17:49 UTC
gnome_vfs_get_volume_monitor() does basically this: if (!the_global_monitor) the_global_monitor = gnome_vfs_volume_monitor_new (); return the_global_monitor; This leads to unclear memory management. It would be better to return a ref to the existing monitor if it has already been created. See bug #145200 for a related issue.
Also, when the refcount of the volume monitor drops to zero, the global the_volume_monitor variable should be set to NULL.
*** Bug 151244 has been marked as a duplicate of this bug. ***
A ref? The volume monitor is a singleton that is guaranteed to not go away. Anyway, making it take a ref is an ABI break that will make all current uses leaks. (Not to mention much more complicated for no apparent reason.)
I guess the real bug is that the file selector doesn't call gnome_vfs_shutdown.
OK, so should I retitle this bug to "GnomeVFSVolumeMonitor should not be refcounted", and provide a patch to make the ref/unref functions no-ops? Code will still do g_object_ref/unref(), of course (e.g. the signal emission code). Apps would of course be buggy if they did one g_object_unref() too many on the volume monitor. We can flame people about this in the finalize function.
See bug 151244 for why ref/unref might still be useful. It also has a patch that includes the flame on finalize if gnome_vfs_shutdown wasn't called. The patch is currently sent to the release-team for consideration.
Can we have a decision on this? Should the singleton be ref-counted or not?
gnome-vfs has been deprecated and superseded by gio/gvfs since GNOME 2.22, hence mass-closing many of the gnome-vfs requests/bug reports. This means that gnome-vfs is NOT actively maintained anymore, however patches are still welcome. If your reported issue is still valid for gio/gvfs, please feel free to file a bug report against glib/gio or gvfs. @Bugzilla mail recipients: query for gnome-vfs-mass-close to get rid of these notification emails all together. General further information: http://en.wikipedia.org/wiki/GVFS Reasons behind this decision are listed at http://www.mail-archive.com/gnome-vfs-list@gnome.org/msg00899.html