[recipes] Avoid a memory leak in shopping list printer



commit 9e11e95aec2655f173b8b7f259a03db06b95bd97
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jan 14 16:03:56 2017 -0500

    Avoid a memory leak in shopping list printer

 src/gr-shopping-list-printer.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/gr-shopping-list-printer.c b/src/gr-shopping-list-printer.c
index 2c9d1f3..c0bd2de 100644
--- a/src/gr-shopping-list-printer.c
+++ b/src/gr-shopping-list-printer.c
@@ -63,8 +63,22 @@ struct _GrShoppingListPrinter
 G_DEFINE_TYPE (GrShoppingListPrinter, gr_shopping_list_printer, G_TYPE_OBJECT)
 
 static void
+finalize (GObject *object)
+{
+        GrShoppingListPrinter *printer = GR_SHOPPING_LIST_PRINTER (object);
+
+        g_clear_object (&printer->layout);
+        g_list_free (printer->page_breaks);
+        g_list_free_full (printer->recipes, g_object_unref);
+        g_list_free_full (printer->items, shopping_item_free);
+
+        G_OBJECT_CLASS (gr_shopping_list_printer_parent_class)->finalize (object);
+}
+
+static void
 gr_shopping_list_printer_class_init (GrShoppingListPrinterClass *klass)
 {
+        G_OBJECT_CLASS (klass)->finalize = finalize;
 }
 
 static void
@@ -266,7 +280,7 @@ draw_page (GtkPrintOperation *operation,
 static void
 print_done (GtkPrintOperation       *operation,
             GtkPrintOperationResult  res,
-            GrShoppingListPrinter         *printer)
+            GrShoppingListPrinter   *printer)
 {
        GError *error = NULL;
 


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