[gtk+] printing: Make sure destroy function is always called by gtk_enumerate_printers



commit 5ebfad5d091f4c9d9c6e60364fad4c60842f027f
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Thu Mar 15 12:10:52 2012 +0100

    printing: Make sure destroy function is always called by gtk_enumerate_printers
    
    When GtkPrinterFunc always returns FALSE, for example when looking for
    a non existent printer, if print list is done for all backends or print
    backend status is UNAVAILABLE, gtk_enumerate_printers() finishes with an
    empty backend list and destroy function is never called. We need to
    check the backend list again after calling list_printers_init for all
    backends and finish the enumeration if it's empty.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672125

 gtk/gtkprinter.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkprinter.c b/gtk/gtkprinter.c
index 05e67e9..ada20b5 100644
--- a/gtk/gtkprinter.c
+++ b/gtk/gtkprinter.c
@@ -1151,15 +1151,10 @@ backend_status_changed (GObject    *object,
 }
 
 static void
-list_done_cb (GtkPrintBackend *backend, 
-	      PrinterList     *printer_list)
+list_printers_remove_backend (PrinterList     *printer_list,
+                              GtkPrintBackend *backend)
 {
   printer_list->backends = g_list_remove (printer_list->backends, backend);
-  
-  g_signal_handlers_disconnect_by_func (backend, list_added_cb, printer_list);
-  g_signal_handlers_disconnect_by_func (backend, list_done_cb, printer_list);
-  g_signal_handlers_disconnect_by_func (backend, backend_status_changed, printer_list);
-  
   gtk_print_backend_destroy (backend);
   g_object_unref (backend);
 
@@ -1167,6 +1162,17 @@ list_done_cb (GtkPrintBackend *backend,
     free_printer_list (printer_list);
 }
 
+static void
+list_done_cb (GtkPrintBackend *backend,
+	      PrinterList     *printer_list)
+{
+  g_signal_handlers_disconnect_by_func (backend, list_added_cb, printer_list);
+  g_signal_handlers_disconnect_by_func (backend, list_done_cb, printer_list);
+  g_signal_handlers_disconnect_by_func (backend, backend_status_changed, printer_list);
+
+  list_printers_remove_backend(printer_list, backend);
+}
+
 static gboolean
 list_printers_init (PrinterList     *printer_list,
 		    GtkPrintBackend *backend)
@@ -1191,11 +1197,7 @@ list_printers_init (PrinterList     *printer_list,
   
   if (status == GTK_PRINT_BACKEND_STATUS_UNAVAILABLE || 
       gtk_print_backend_printer_list_is_done (backend))
-    {
-      printer_list->backends = g_list_remove (printer_list->backends, backend);
-      gtk_print_backend_destroy (backend);
-      g_object_unref (backend);
-    }
+    list_printers_remove_backend(printer_list, backend);
   else
     {
       g_signal_connect (backend, "printer-added", 



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