diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-06-01 07:43:54 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-06-01 13:52:21 -0400 |
commit | 7a50f86f3f3970d78cb207f74803c20897069718 (patch) | |
tree | 3365ff8702b1b73bbe6a8a284db4c2d783664e63 /gtk/gtkprintbackend.c | |
parent | 59218d02c8b37c38cb0cc151c80712ff7078a836 (diff) | |
download | gtk+-7a50f86f3f3970d78cb207f74803c20897069718.tar.gz |
print backend: Fix list model handling in dispose
The print backends do some complicated dispose handling
where the implementations call gtk_print_backend_destroy().
Our tests (in particular, the templates test) trigger
situations where we use print backends after dispose,
and they can't handle the printers listmodel being
NULL at that time. So just remove the printers in
dispose, keep the empty liststore until finalize.
Diffstat (limited to 'gtk/gtkprintbackend.c')
-rw-r--r-- | gtk/gtkprintbackend.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/gtk/gtkprintbackend.c b/gtk/gtkprintbackend.c index eadd4125d5..2071379a1b 100644 --- a/gtk/gtkprintbackend.c +++ b/gtk/gtkprintbackend.c @@ -29,6 +29,7 @@ #include "gtkprintbackendprivate.h" +static void gtk_print_backend_finalize (GObject *object); static void gtk_print_backend_dispose (GObject *object); static void gtk_print_backend_set_property (GObject *object, guint prop_id, @@ -251,6 +252,7 @@ gtk_print_backend_class_init (GtkPrintBackendClass *class) backend_parent_class = g_type_class_peek_parent (class); + object_class->finalize = gtk_print_backend_finalize; object_class->dispose = gtk_print_backend_dispose; object_class->set_property = gtk_print_backend_set_property; object_class->get_property = gtk_print_backend_get_property; @@ -348,11 +350,21 @@ gtk_print_backend_dispose (GObject *object) /* We unref the printers in dispose, not in finalize so that * we can break refcount cycles with gtk_print_backend_destroy */ - g_clear_object (&priv->printers); + g_list_store_remove_all (priv->printers); backend_parent_class->dispose (object); } +static void +gtk_print_backend_finalize (GObject *object) +{ + GtkPrintBackend *backend = GTK_PRINT_BACKEND (object); + GtkPrintBackendPrivate *priv = backend->priv; + + g_clear_object (&priv->printers); + + backend_parent_class->finalize (object); +} static void fallback_printer_request_details (GtkPrinter *printer) @@ -361,7 +373,7 @@ fallback_printer_request_details (GtkPrinter *printer) static gboolean fallback_printer_mark_conflicts (GtkPrinter *printer, - GtkPrinterOptionSet *options) + GtkPrinterOptionSet *options) { return FALSE; } |