GNOME Bugzilla – Bug 547088
wrap g_content_types_get_registered()
Last modified: 2008-08-27 21:28:56 UTC
Patch follows.
Created attachment 116254 [details] [review] patch + two helper functions I also wrote pyglib_pylist_from_glist() and pyglib_convert_glist_to_pylist() helpers. First creates a list of Python objects from GList, second does the same, but additionally destroys GList (i.e. destructive conversion). This is apparently done often in PyGObject and PyGTK, so we can reduce code repetition and be less error-prone by using a helper.
Created attachment 116260 [details] [review] patch + two helper functions and using the helpers all over pygobject lib At request of Johan, the helpers are used in all cases I detected conversion of GList to Python list. I found several cases where old code leaked references to GObject's: documentation explicitly tells that you must g_object_unref list items before freeing the list, but wrappers didn't do that. I guess that could have become a major memory leak.
Comment on attachment 116260 [details] [review] patch + two helper functions and using the helpers all over pygobject lib Rock on! I don't quite like the naming. What about: pyglib_list_from_glist pyglib_list_from_glist_full ?
Created attachment 117474 [details] [review] patch + fixes for reference/memory leaks in GList-returning functions As we cannot agree on best names and semantics, helpers are postponed till the next release. Meanwhile, this patch adds the function and fixes leaks that were present in most other GList-returning functions in PyGObject.
Sending ChangeLog Sending gio/gfileenumerator.override Sending gio/gio.override Sending gio/gvolumemonitor.override Transmitting file data .... Committed revision 951. 2008-08-28 Paul Pogonyshev <pogonyshev@gmx.net> Bug 547088 – wrap g_content_types_get_registered() * gio/gio.override (_wrap_g_drive_get_volumes): Fix refleak. (_wrap_g_content_types_get_registered): New function. * gio/gfileenumerator.override (_wrap_g_file_enumerator_next_files_finish): Fix refleak. * gio/gvolumemonitor.override (_wrap_g_volume_monitor_get_connected_drives): Fix refleak. (_wrap_g_volume_monitor_get_volumes): Likewise. (_wrap_g_volume_monitor_get_mounts): Likewise.