[gedit/wip/printing-enhancements: 2/3] Call gtk_print_operation_preview_end_preview() in PrintPreview
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/printing-enhancements: 2/3] Call gtk_print_operation_preview_end_preview() in PrintPreview
- Date: Sun, 28 Jun 2015 06:34:12 +0000 (UTC)
commit 399ae69249eb4285ca4facb12c56d39988083066
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Jun 28 06:42:14 2015 +0200
Call gtk_print_operation_preview_end_preview() in PrintPreview
In PrintJob, we are not sure that we have a ref to gtk_preview. On the
other hand PrintPreview refs/unrefs gtk_preview, so it's safer.
gedit/gedit-print-job.c | 13 -------------
gedit/gedit-print-preview.c | 17 ++++++++++++++++-
2 files changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/gedit/gedit-print-job.c b/gedit/gedit-print-job.c
index b852e56..7589469 100644
--- a/gedit/gedit-print-job.c
+++ b/gedit/gedit-print-job.c
@@ -439,13 +439,6 @@ preview_ready (GtkPrintOperationPreview *gtk_preview,
g_clear_object (&job->preview);
}
-static void
-preview_destroyed (GtkWidget *preview,
- GtkPrintOperationPreview *gtk_preview)
-{
- gtk_print_operation_preview_end_preview (gtk_preview);
-}
-
static gboolean
preview_cb (GtkPrintOperation *op,
GtkPrintOperationPreview *gtk_preview,
@@ -462,12 +455,6 @@ preview_cb (GtkPrintOperation *op,
G_CALLBACK (preview_ready),
job);
- /* FIXME: should this go in the preview widget itself? */
- g_signal_connect (job->preview,
- "destroy",
- G_CALLBACK (preview_destroyed),
- gtk_preview);
-
return TRUE;
}
diff --git a/gedit/gedit-print-preview.c b/gedit/gedit-print-preview.c
index fabd87c..2709745 100644
--- a/gedit/gedit-print-preview.c
+++ b/gedit/gedit-print-preview.c
@@ -85,9 +85,24 @@ gedit_print_preview_dispose (GObject *object)
{
GeditPrintPreview *preview = GEDIT_PRINT_PREVIEW (object);
+ if (preview->gtk_preview != NULL)
+ {
+ GtkPrintOperationPreview *gtk_preview;
+
+ /* Set preview->gtk_preview to NULL because when calling
+ * end_preview() this dispose() function can be run a second
+ * time.
+ */
+ gtk_preview = preview->gtk_preview;
+ preview->gtk_preview = NULL;
+
+ gtk_print_operation_preview_end_preview (gtk_preview);
+
+ g_object_unref (gtk_preview);
+ }
+
g_clear_object (&preview->operation);
g_clear_object (&preview->context);
- g_clear_object (&preview->gtk_preview);
G_OBJECT_CLASS (gedit_print_preview_parent_class)->dispose (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]