[gtk+/gtk-2-24] printing: Make sure destroy function is always called by gtk_enumerate_printers
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] printing: Make sure destroy function is always called by gtk_enumerate_printers
- Date: Thu, 15 Mar 2012 13:49:19 +0000 (UTC)
commit 9a0e81380bfdc0abebbfa657abc974afeea6027b
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 a38be43..479b8c7 100644
--- a/gtk/gtkprinter.c
+++ b/gtk/gtkprinter.c
@@ -1137,15 +1137,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);
@@ -1153,6 +1148,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)
@@ -1177,11 +1183,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]