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 547088 - wrap g_content_types_get_registered()
wrap g_content_types_get_registered()
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gio
Git master
Other All
: Normal enhancement
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2008-08-09 18:10 UTC by Paul Pogonyshev
Modified: 2008-08-27 21:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch + two helper functions (3.29 KB, patch)
2008-08-09 18:12 UTC, Paul Pogonyshev
none Details | Review
patch + two helper functions and using the helpers all over pygobject lib (9.17 KB, patch)
2008-08-09 19:12 UTC, Paul Pogonyshev
none Details | Review
patch + fixes for reference/memory leaks in GList-returning functions (1.99 KB, patch)
2008-08-27 19:22 UTC, Paul Pogonyshev
committed Details | Review

Description Paul Pogonyshev 2008-08-09 18:10:16 UTC
Patch follows.
Comment 1 Paul Pogonyshev 2008-08-09 18:12:31 UTC
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.
Comment 2 Paul Pogonyshev 2008-08-09 19:12:35 UTC
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 3 Johan (not receiving bugmail) Dahlin 2008-08-09 19:18:18 UTC
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 ?
Comment 4 Paul Pogonyshev 2008-08-27 19:22:48 UTC
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.
Comment 5 Paul Pogonyshev 2008-08-27 21:28:56 UTC
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.