[gnome-photos/wip/rishi/camera-cache-g-auto] camera-cache: Limit the scope of the GError
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/camera-cache-g-auto] camera-cache: Limit the scope of the GError
- Date: Tue, 30 Mar 2021 23:00:28 +0000 (UTC)
commit 4a0b7072922714a5922d2757b082d3ef69d80467
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Mar 31 00:59:45 2021 +0200
camera-cache: 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.
https://gitlab.gnome.org/GNOME/gnome-photos/-/merge_requests/206
src/photos-camera-cache.c | 42 +++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)
---
diff --git a/src/photos-camera-cache.c b/src/photos-camera-cache.c
index 244cd5af..dc02feae 100644
--- a/src/photos-camera-cache.c
+++ b/src/photos-camera-cache.c
@@ -47,7 +47,6 @@ photos_camera_cache_cursor_next (GObject *source_object, GAsyncResult *res, gpoi
g_autoptr (GTask) task = G_TASK (user_data);
PhotosCameraCache *self;
TrackerSparqlCursor *cursor = TRACKER_SPARQL_CURSOR (source_object);
- GError *error;
gboolean success;
const gchar *manufacturer;
const gchar *model;
@@ -56,16 +55,19 @@ photos_camera_cache_cursor_next (GObject *source_object, GAsyncResult *res, gpoi
self = PHOTOS_CAMERA_CACHE (g_task_get_source_object (task));
- error = NULL;
- /* Note that tracker_sparql_cursor_next_finish can return FALSE even
- * without an error.
- */
- success = tracker_sparql_cursor_next_finish (cursor, res, &error);
- if (error != NULL)
- {
- g_task_return_error (task, error);
- goto out;
- }
+ {
+ g_autoptr (GError) error = NULL;
+
+ /* Note that tracker_sparql_cursor_next_finish can return FALSE even
+ * without an error.
+ */
+ success = tracker_sparql_cursor_next_finish (cursor, res, &error);
+ if (error != NULL)
+ {
+ g_task_return_error (task, g_steal_pointer (&error));
+ goto out;
+ }
+ }
/* Note that the following SPARQL query:
* SELECT nfo:manufacturer (<(foo)>) nfo:model (<(foo)>) WHERE {}
@@ -106,15 +108,17 @@ photos_camera_cache_equipment_query_executed (GObject *source_object, GAsyncResu
GTask *task = G_TASK (user_data);
TrackerSparqlConnection *connection = TRACKER_SPARQL_CONNECTION (source_object);
g_autoptr (TrackerSparqlCursor) cursor = NULL;
- GError *error;
- error = NULL;
- cursor = tracker_sparql_connection_query_finish (connection, res, &error);
- if (error != NULL)
- {
- g_task_return_error (task, error);
- goto out;
- }
+ {
+ g_autoptr (GError) error = NULL;
+
+ cursor = tracker_sparql_connection_query_finish (connection, res, &error);
+ if (error != NULL)
+ {
+ g_task_return_error (task, g_steal_pointer (&error));
+ goto out;
+ }
+ }
tracker_sparql_cursor_next_async (cursor, NULL, photos_camera_cache_cursor_next, g_object_ref (task));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]