[gnome-control-center] printers: Use g_clear_object with cancellable



commit 983857e8276e033ad952fda518559e1f11517d79
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Nov 23 11:14:22 2018 +1300

    printers: Use g_clear_object with cancellable
    
    Safer than g_object_unref.
    Also remove explicit initialization to NULL - all values start as NULL.

 panels/printers/pp-new-printer.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/panels/printers/pp-new-printer.c b/panels/printers/pp-new-printer.c
index ffb131ee8..3c144c1f0 100644
--- a/panels/printers/pp-new-printer.c
+++ b/panels/printers/pp-new-printer.c
@@ -103,8 +103,7 @@ pp_new_printer_finalize (GObject *object)
   g_clear_pointer (&priv->make_and_model, g_free);
   g_clear_pointer (&priv->host_name, g_free);
   g_clear_object (&priv->task);
-  if (priv->cancellable)
-    g_object_unref (priv->cancellable);
+  g_clear_object (&priv->cancellable);
 
   G_OBJECT_CLASS (pp_new_printer_parent_class)->finalize (object);
 }
@@ -347,7 +346,6 @@ pp_new_printer_init (PpNewPrinter *printer)
                                                PpNewPrinterPrivate);
 
   printer->priv->unlink_ppd_file = FALSE;
-  printer->priv->cancellable = NULL;
 }
 
 PpNewPrinter *
@@ -804,8 +802,7 @@ printer_configure_async_finish (PCData *data)
     {
       _pp_new_printer_add_async_cb (TRUE, data->new_printer);
 
-      if (data->cancellable)
-        g_object_unref (data->cancellable);
+      g_clear_object (&data->cancellable);
       g_free (data);
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]