[gnome-photos] base-item: Use g_auto* (3/3)
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] base-item: Use g_auto* (3/3)
- Date: Wed, 13 Dec 2017 12:00:24 +0000 (UTC)
commit d7254bcce6e8d35054b11b07b0bfb04643916a12
Author: Umang Jain <mailumangjain gmail com>
Date: Sun Dec 3 00:15:14 2017 +0530
base-item: Use g_auto* (3/3)
https://bugzilla.gnome.org/show_bug.cgi?id=788174
src/photos-base-item.c | 127 ++++++++++++++++++++---------------------------
1 files changed, 54 insertions(+), 73 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index cb2c3b3..7c6197c 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -2753,49 +2753,50 @@ static void
photos_base_item_print_load (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
PhotosBaseItem *self = PHOTOS_BASE_ITEM (source_object);
- GError *error;
- GtkWindow *toplevel = GTK_WINDOW (user_data);
- GeglNode *node;
- GtkPrintOperation *print_op = NULL;
+ g_autoptr (GtkWindow) toplevel = GTK_WINDOW (user_data);
+ g_autoptr (GeglNode) node = NULL;
+ g_autoptr (GtkPrintOperation) print_op = NULL;
GtkPrintOperationResult print_res;
- error = NULL;
- node = photos_base_item_load_finish (self, res, &error);
- if (error != NULL)
- {
- g_warning ("Unable to load the item: %s", error->message);
- g_error_free (error);
- goto out;
- }
+ {
+ g_autoptr (GError) error = NULL;
+
+ node = photos_base_item_load_finish (self, res, &error);
+ if (error != NULL)
+ {
+ g_warning ("Unable to load the item: %s", error->message);
+ goto out;
+ }
+ }
print_op = photos_print_operation_new (self, node);
/* It is self managing. */
photos_print_notification_new (print_op);
- error = NULL;
- print_res = gtk_print_operation_run (print_op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, toplevel, &error);
- if (print_res == GTK_PRINT_OPERATION_RESULT_APPLY)
- {
- GAction *action;
- GApplication *app;
- GVariant *new_state;
-
- app = g_application_get_default ();
- action = g_action_map_lookup_action (G_ACTION_MAP (app), "selection-mode");
- new_state = g_variant_new ("b", FALSE);
- g_action_change_state (action, new_state);
- }
- else if (print_res == GTK_PRINT_OPERATION_RESULT_ERROR)
- {
- g_warning ("Unable to print file: %s", error->message);
- g_error_free (error);
- }
+ {
+ g_autoptr (GError) error = NULL;
+
+ print_res = gtk_print_operation_run (print_op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, toplevel,
&error);
+ if (print_res == GTK_PRINT_OPERATION_RESULT_APPLY)
+ {
+ GAction *action;
+ GApplication *app;
+ GVariant *new_state;
+
+ app = g_application_get_default ();
+ action = g_action_map_lookup_action (G_ACTION_MAP (app), "selection-mode");
+ new_state = g_variant_new ("b", FALSE);
+ g_action_change_state (action, new_state);
+ }
+ else if (print_res == GTK_PRINT_OPERATION_RESULT_ERROR)
+ {
+ g_warning ("Unable to print file: %s", error->message);
+ }
+ }
out:
- g_clear_object (&node);
- g_clear_object (&print_op);
- g_object_unref (toplevel);
+ return;
}
@@ -3085,7 +3086,7 @@ photos_base_item_create_preview (PhotosBaseItem *self,
const Babl *format;
GeglBuffer *preview_source_buffer;
GeglNode *buffer_source;
- GeglNode *graph = NULL;
+ g_autoptr (GeglNode) graph = NULL;
GeglNode *operation_node;
GeglOperation *op;
GeglRectangle bbox;
@@ -3152,8 +3153,6 @@ photos_base_item_create_preview (PhotosBaseItem *self,
cairo_surface_set_device_scale (surface, (gdouble) scale, (gdouble) scale);
cairo_surface_set_user_data (surface, &key, buf, (cairo_destroy_func_t) g_free);
- g_object_unref (graph);
-
return surface;
}
@@ -3194,7 +3193,7 @@ photos_base_item_download_async (PhotosBaseItem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GTask *task;
+ g_autoptr (GTask) task = NULL;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
@@ -3202,7 +3201,6 @@ photos_base_item_download_async (PhotosBaseItem *self,
g_task_set_source_tag (task, photos_base_item_download_async);
g_task_run_in_thread (task, photos_base_item_download_in_thread_func);
- g_object_unref (task);
}
@@ -3601,7 +3599,7 @@ photos_base_item_guess_save_sizes_async (PhotosBaseItem *self,
gpointer user_data)
{
PhotosBaseItemPrivate *priv;
- GTask *task;
+ g_autoptr (GTask) task = NULL;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
priv = photos_base_item_get_instance_private (self);
@@ -3612,8 +3610,6 @@ photos_base_item_guess_save_sizes_async (PhotosBaseItem *self,
g_task_set_source_tag (task, photos_base_item_guess_save_sizes_async);
photos_base_item_load_async (self, cancellable, photos_base_item_guess_save_sizes_load, g_object_ref
(task));
-
- g_object_unref (task);
}
@@ -3719,7 +3715,7 @@ photos_base_item_load_async (PhotosBaseItem *self,
gpointer user_data)
{
PhotosBaseItemPrivate *priv;
- GTask *task = NULL;
+ g_autoptr (GTask) task = NULL;
PhotosPipeline *pipeline;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
@@ -3748,7 +3744,7 @@ photos_base_item_load_async (PhotosBaseItem *self,
g_object_ref (task));
out:
- g_clear_object (&task);
+ return;
}
@@ -3779,7 +3775,7 @@ photos_base_item_metadata_add_shared_async (PhotosBaseItem *self,
gpointer user_data)
{
PhotosBaseItemPrivate *priv;
- GTask *task;
+ g_autoptr (GTask) task = NULL;
PhotosBaseItemMetadataAddSharedData *data;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
@@ -3797,7 +3793,6 @@ photos_base_item_metadata_add_shared_async (PhotosBaseItem *self,
g_task_set_task_data (task, data, (GDestroyNotify) photos_base_item_metadata_add_shared_data_free);
g_task_run_in_thread (task, photos_base_item_metadata_add_shared_in_thread_func);
- g_object_unref (task);
}
@@ -3836,7 +3831,7 @@ photos_base_item_operation_add_async (PhotosBaseItem *self,
...)
{
PhotosBaseItemPrivate *priv;
- GTask *task;
+ g_autoptr (GTask) task = NULL;
PhotosPipeline *pipeline;
va_list ap;
@@ -3856,8 +3851,6 @@ photos_base_item_operation_add_async (PhotosBaseItem *self,
g_task_set_source_tag (task, photos_base_item_operation_add_async);
photos_base_item_process_async (self, cancellable, photos_base_item_common_process, g_object_ref (task));
-
- g_object_unref (task);
}
@@ -3910,7 +3903,7 @@ photos_base_item_operation_remove_async (PhotosBaseItem *self,
gpointer user_data)
{
PhotosBaseItemPrivate *priv;
- GTask *task;
+ g_autoptr (GTask) task = NULL;
PhotosPipeline *pipeline;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
@@ -3933,7 +3926,7 @@ photos_base_item_operation_remove_async (PhotosBaseItem *self,
photos_base_item_process_async (self, cancellable, photos_base_item_common_process, g_object_ref (task));
out:
- g_object_unref (task);
+ return;
}
@@ -3961,7 +3954,7 @@ photos_base_item_pipeline_is_edited_async (PhotosBaseItem *self,
gpointer user_data)
{
PhotosBaseItemPrivate *priv;
- GTask *task;
+ g_autoptr (GTask) task = NULL;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
priv = photos_base_item_get_instance_private (self);
@@ -3975,8 +3968,6 @@ photos_base_item_pipeline_is_edited_async (PhotosBaseItem *self,
cancellable,
photos_base_item_pipeline_is_edited_load_pipeline,
g_object_ref (task));
-
- g_object_unref (task);
}
@@ -4004,7 +3995,7 @@ photos_base_item_pipeline_revert_async (PhotosBaseItem *self,
gpointer user_data)
{
PhotosBaseItemPrivate *priv;
- GTask *task = NULL;
+ g_autoptr (GTask) task = NULL;
PhotosPipeline *pipeline;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
@@ -4029,7 +4020,7 @@ photos_base_item_pipeline_revert_async (PhotosBaseItem *self,
photos_base_item_process_async (self, cancellable, photos_base_item_common_process, g_object_ref (task));
out:
- g_clear_object (&task);
+ return;
}
@@ -4058,7 +4049,7 @@ photos_base_item_pipeline_revert_to_original_async (PhotosBaseItem *self,
{
PhotosBaseItemPrivate *priv;
- GTask *task = NULL;
+ g_autoptr (GTask) task = NULL;
PhotosPipeline *pipeline;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
@@ -4083,7 +4074,7 @@ photos_base_item_pipeline_revert_to_original_async (PhotosBaseItem *self,
photos_base_item_process_async (self, cancellable, photos_base_item_common_process, g_object_ref (task));
out:
- g_clear_object (&task);
+ return;
}
@@ -4111,7 +4102,7 @@ photos_base_item_pipeline_save_async (PhotosBaseItem *self,
gpointer user_data)
{
PhotosBaseItemPrivate *priv;
- GTask *task;
+ g_autoptr (GTask) task = NULL;
PhotosPipeline *pipeline;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
@@ -4126,8 +4117,6 @@ photos_base_item_pipeline_save_async (PhotosBaseItem *self,
g_task_set_source_tag (task, photos_base_item_pipeline_save_async);
photos_pipeline_save_async (pipeline, cancellable, photos_base_item_pipeline_save_save, g_object_ref
(task));
-
- g_object_unref (task);
}
@@ -4186,7 +4175,7 @@ photos_base_item_refresh (PhotosBaseItem *self)
PhotosBaseItemPrivate *priv;
GApplication *app;
PhotosSearchContextState *state;
- PhotosSingleItemJob *job;
+ g_autoptr (PhotosSingleItemJob) job = NULL;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
priv = photos_base_item_get_instance_private (self);
@@ -4201,7 +4190,6 @@ photos_base_item_refresh (PhotosBaseItem *self)
NULL,
photos_base_item_refresh_executed,
g_object_ref (self));
- g_object_unref (job);
}
@@ -4214,7 +4202,7 @@ photos_base_item_save_to_dir_async (PhotosBaseItem *self,
gpointer user_data)
{
PhotosBaseItemPrivate *priv;
- GTask *task;
+ g_autoptr (GTask) task = NULL;
PhotosBaseItemSaveData *data;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
@@ -4231,8 +4219,6 @@ photos_base_item_save_to_dir_async (PhotosBaseItem *self,
g_task_set_task_data (task, data, (GDestroyNotify) photos_base_item_save_data_free);
photos_base_item_load_async (self, cancellable, photos_base_item_save_to_dir_load, g_object_ref (task));
-
- g_object_unref (task);
}
@@ -4263,7 +4249,7 @@ photos_base_item_save_to_file_async (PhotosBaseItem *self,
gpointer user_data)
{
PhotosBaseItemPrivate *priv;
- GTask *task;
+ g_autoptr (GTask) task = NULL;
PhotosBaseItemSaveToFileData *data;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
@@ -4279,8 +4265,6 @@ photos_base_item_save_to_file_async (PhotosBaseItem *self,
g_task_set_task_data (task, data, (GDestroyNotify) photos_base_item_save_to_file_data_free);
photos_base_item_load_async (self, cancellable, photos_base_item_save_to_file_load, g_object_ref (task));
-
- g_object_unref (task);
}
@@ -4310,7 +4294,7 @@ photos_base_item_save_to_stream_async (PhotosBaseItem *self,
gpointer user_data)
{
PhotosBaseItemPrivate *priv;
- GTask *task;
+ g_autoptr (GTask) task = NULL;
PhotosBaseItemSaveToStreamData *data;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
@@ -4327,8 +4311,6 @@ photos_base_item_save_to_stream_async (PhotosBaseItem *self,
g_task_set_task_data (task, data, (GDestroyNotify) photos_base_item_save_to_stream_data_free);
photos_base_item_load_async (self, cancellable, photos_base_item_save_to_stream_load, g_object_ref (task));
-
- g_object_unref (task);
}
@@ -4407,7 +4389,7 @@ void
photos_base_item_trash (PhotosBaseItem *self)
{
PhotosBaseItemPrivate *priv;
- PhotosDeleteItemJob *job;
+ g_autoptr (PhotosDeleteItemJob) job = NULL;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
priv = photos_base_item_get_instance_private (self);
@@ -4416,5 +4398,4 @@ photos_base_item_trash (PhotosBaseItem *self)
job = photos_delete_item_job_new (priv->id);
photos_delete_item_job_run (job, NULL, NULL, NULL);
- g_object_unref (job);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]