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 629247 - add gsimpleasyncresult methods to take over a GError
add gsimpleasyncresult methods to take over a GError
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-09-10 09:59 UTC by Christian Persch
Modified: 2010-11-01 02:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add g_simple_async_result_new_take_error and ..._take_from_error (7.15 KB, patch)
2010-09-10 10:00 UTC, Christian Persch
none Details | Review

Description Christian Persch 2010-09-10 09:59:39 UTC
A common code pattern in gio is

g_simple_async_result_new_from_error(..., error)
g_error_free (error);

and

g_simple_async_result_set_from_error (result, error);
g_error_free (error);

This does an unnecessary copy of the GError, when it could just as well take over the caller's ownership.

Attached patch adds g_simple_async_result_new_take_error() and g_simple_async_result_take_from_error() [not too sure about the naming on that one].

If it's accepted, I will provide a further patch that ports over instances of the above patterns in gio to the new functions.
Comment 1 Christian Persch 2010-09-10 10:00:26 UTC
Created attachment 169934 [details] [review]
Add g_simple_async_result_new_take_error and ..._take_from_error

This allows transferring ownership of the #GError, so there's no
needless duplication.

Bug #629247.
Comment 2 Matthias Clasen 2010-09-10 12:18:42 UTC
Sounds like a reasonable idea, and the patch looks fine. But we should probably hold it until 2.27, at this point.
Comment 3 Christian Persch 2010-09-23 10:27:07 UTC
So is this ok-to-commit now that 2-26 is branched off? :)
Comment 4 Christian Persch 2010-09-23 10:28:29 UTC
Also, about the naming: I used g_simple_async_result_take_from_error() in the patch, but maybe g_simple_async_result_take_error() is simpler and nicer?