Commit 5ebfad5d authored by Carlos Garcia Campos's avatar Carlos Garcia Campos Committed by Carlos Garcia Campos

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
parent 3778999a
...@@ -1151,15 +1151,10 @@ backend_status_changed (GObject *object, ...@@ -1151,15 +1151,10 @@ backend_status_changed (GObject *object,
} }
static void static void
list_done_cb (GtkPrintBackend *backend, list_printers_remove_backend (PrinterList *printer_list,
PrinterList *printer_list) GtkPrintBackend *backend)
{ {
printer_list->backends = g_list_remove (printer_list->backends, 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); gtk_print_backend_destroy (backend);
g_object_unref (backend); g_object_unref (backend);
...@@ -1167,6 +1162,17 @@ list_done_cb (GtkPrintBackend *backend, ...@@ -1167,6 +1162,17 @@ list_done_cb (GtkPrintBackend *backend,
free_printer_list (printer_list); 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 static gboolean
list_printers_init (PrinterList *printer_list, list_printers_init (PrinterList *printer_list,
GtkPrintBackend *backend) GtkPrintBackend *backend)
...@@ -1191,11 +1197,7 @@ list_printers_init (PrinterList *printer_list, ...@@ -1191,11 +1197,7 @@ list_printers_init (PrinterList *printer_list,
if (status == GTK_PRINT_BACKEND_STATUS_UNAVAILABLE || if (status == GTK_PRINT_BACKEND_STATUS_UNAVAILABLE ||
gtk_print_backend_printer_list_is_done (backend)) gtk_print_backend_printer_list_is_done (backend))
{ list_printers_remove_backend(printer_list, backend);
printer_list->backends = g_list_remove (printer_list->backends, backend);
gtk_print_backend_destroy (backend);
g_object_unref (backend);
}
else else
{ {
g_signal_connect (backend, "printer-added", g_signal_connect (backend, "printer-added",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment