[gnome-photos] pixbuf: Limit the scope of the GError
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] pixbuf: Limit the scope of the GError
- Date: Sat, 30 Dec 2017 21:07:00 +0000 (UTC)
commit ae2f16c0ab974cd7125766a782c212f2fd76bb75
Author: Debarshi Ray <debarshir gnome org>
Date: Sat Dec 30 21:55:42 2017 +0100
pixbuf: Limit the scope of the GError
Even though it's not strictly necessary here, it's a good style to
follow. It reduces the chances of re-using the same GError without
ensuring that it is empty, and emphasizes that g_task_return_error
assumes ownership of the GError.
src/photos-pixbuf.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/src/photos-pixbuf.c b/src/photos-pixbuf.c
index 9480ae93..85de6617 100644
--- a/src/photos-pixbuf.c
+++ b/src/photos-pixbuf.c
@@ -62,17 +62,19 @@ photos_pixbuf_new_from_file_at_size_in_thread_func (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
- GError *error;
g_autoptr (GdkPixbuf) result = NULL;
PhotosPixbufNewFromFileData *data = (PhotosPixbufNewFromFileData *) task_data;
- error = NULL;
- result = gdk_pixbuf_new_from_file_at_size (data->filename, data->width, data->height, &error);
- if (error != NULL)
- {
- g_task_return_error (task, error);
- goto out;
- }
+ {
+ g_autoptr (GError) error = NULL;
+
+ result = gdk_pixbuf_new_from_file_at_size (data->filename, data->width, data->height, &error);
+ if (error != NULL)
+ {
+ g_task_return_error (task, g_steal_pointer (&error));
+ goto out;
+ }
+ }
g_task_return_pointer (task, g_object_ref (result), g_object_unref);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]