[gnome-control-center] printers: Don't pass ownership in get_all_ppds_async callback
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Don't pass ownership in get_all_ppds_async callback
- Date: Sun, 14 Feb 2021 21:39:10 +0000 (UTC)
commit 5b086c44e8e85d5e3d43dbec56fee8c07e37ea55
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Feb 12 15:13:21 2021 +1300
printers: Don't pass ownership in get_all_ppds_async callback
panels/printers/cc-printers-panel.c | 2 +-
panels/printers/pp-details-dialog.c | 2 +-
panels/printers/pp-utils.c | 17 +++++------------
3 files changed, 7 insertions(+), 14 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index 9d8505a1c..4c7d3f779 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -1089,7 +1089,7 @@ get_all_ppds_async_cb (PPDList *ppds,
{
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
- self->all_ppds_list = ppds;
+ self->all_ppds_list = ppd_list_copy (ppds);
if (self->pp_new_printer_dialog)
pp_new_printer_dialog_set_ppd_list (self->pp_new_printer_dialog,
diff --git a/panels/printers/pp-details-dialog.c b/panels/printers/pp-details-dialog.c
index 4e5039f47..d6b13c8f3 100644
--- a/panels/printers/pp-details-dialog.c
+++ b/panels/printers/pp-details-dialog.c
@@ -164,7 +164,7 @@ get_all_ppds_async_cb (PPDList *ppds,
{
PpDetailsDialog *self = user_data;
- self->all_ppds_list = ppds;
+ self->all_ppds_list = ppd_list_copy (ppds);
if (self->pp_ppd_selection_dialog)
pp_ppd_selection_dialog_set_ppd_list (self->pp_ppd_selection_dialog,
diff --git a/panels/printers/pp-utils.c b/panels/printers/pp-utils.c
index a911503b2..79ee4f0e7 100644
--- a/panels/printers/pp-utils.c
+++ b/panels/printers/pp-utils.c
@@ -2396,6 +2396,8 @@ gap_data_new (GCancellable *cancellable, GAPCallback callback, gpointer user_dat
static void
gap_data_free (GAPData *data)
{
+ if (data->result != NULL)
+ ppd_list_free (data->result);
g_clear_object (&data->cancellable);
if (data->context)
g_main_context_unref (data->context);
@@ -2405,19 +2407,10 @@ gap_data_free (GAPData *data)
static gboolean
get_all_ppds_idle_cb (gpointer user_data)
{
- GAPData *data = (GAPData *) user_data;
+ GAPData *data = user_data;
- /* Don't call callback if cancelled */
- if (data->cancellable &&
- g_cancellable_is_cancelled (data->cancellable))
- {
- ppd_list_free (data->result);
- data->result = NULL;
- }
- else
- {
- data->callback (data->result, data->user_data);
- }
+ if (!g_cancellable_is_cancelled (data->cancellable))
+ data->callback (data->result, data->user_data);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]