[gtk/matthiasc/for-master: 6/8] print backend: Fix list model handling in dispose
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 6/8] print backend: Fix list model handling in dispose
- Date: Mon, 1 Jun 2020 18:20:33 +0000 (UTC)
commit 7a50f86f3f3970d78cb207f74803c20897069718
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jun 1 07:43:54 2020 -0400
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.
gtk/gtkprintbackend.c | 16 ++++++++++++++--
1 file 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]