summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2007-04-30 04:50:49 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2007-04-30 04:50:49 +0000
commite23495daee0e5d9fd9ef07549d637d9c69b979b9 (patch)
tree9ad9031c95ce1a1ee2d4545e664aaae76aaf1cfb
parent08bf8df1a08c4759dba95d75834d7e2bed400215 (diff)
downloadgdk-pixbuf-e23495daee0e5d9fd9ef07549d637d9c69b979b9.tar.gz
Fix some issues with reference handling in the printing code. (#429902,
2007-04-29 Matthias Clasen <mclasen@redhat.com> Fix some issues with reference handling in the printing code. (#429902, Mathias Hasselmann) * gtk/gtkprintoperation.c (gtk_print_operation_finalize): Unref the print context, if we have one. (gtk_print_operation_done): Add a default ::done handler that unrefs the print context. (preview_ready): Take a reference on the print operation preview here. (print_pages_idle): ...not here, (preview_print_idle_done): ...and release it here. * tests/print-editor.c (preview_cb): Take a reference on the print operation here. svn path=/branches/gtk-2-10/; revision=17723
-rw-r--r--ChangeLog19
-rw-r--r--gtk/gtkprintoperation.c22
-rw-r--r--tests/print-editor.c2
3 files changed, 39 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 110b7962d..7fd875357 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,25 @@
Merge from trunk:
+ Fix some issues with reference handling in the printing
+ code. (#429902, Mathias Hasselmann)
+
+ * gtk/gtkprintoperation.c (gtk_print_operation_finalize):
+ Unref the print context, if we have one.
+ (gtk_print_operation_done): Add a default ::done handler
+ that unrefs the print context.
+ (preview_ready): Take a reference on the print operation
+ preview here.
+ (print_pages_idle): ...not here,
+ (preview_print_idle_done): ...and release it here.
+
+ * tests/print-editor.c (preview_cb): Take a reference
+ on the print operation here.
+
+2007-04-29 Matthias Clasen <mclasen@redhat.com>
+
+ Merge from trunk:
+
Make the emission of ::end-print and ::done consistent
for previews. (#347567, Yevgen Muntyan)
diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c
index a7347c746..1684c801f 100644
--- a/gtk/gtkprintoperation.c
+++ b/gtk/gtkprintoperation.c
@@ -120,6 +120,9 @@ gtk_print_operation_finalize (GObject *object)
if (priv->print_settings)
g_object_unref (priv->print_settings);
+ if (priv->print_context)
+ g_object_unref (priv->print_context);
+
g_free (priv->export_filename);
g_free (priv->job_name);
g_free (priv->custom_tab_label);
@@ -398,6 +401,8 @@ preview_print_idle_done (gpointer data)
g_free (pop->filename);
gtk_print_operation_preview_end_preview (pop->preview);
+
+ g_object_unref (op);
g_free (pop);
GDK_THREADS_LEAVE ();
@@ -455,6 +460,7 @@ preview_ready (GtkPrintOperationPreview *preview,
pop->page_nr = 0;
pop->print_context = context;
+ g_object_ref (preview);
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE + 10,
preview_print_idle,
pop,
@@ -503,6 +509,18 @@ gtk_print_operation_create_custom_widget (GtkPrintOperation *operation)
return NULL;
}
+static void
+gtk_print_operation_done (GtkPrintOperation *operation)
+{
+ GtkPrintOperationPrivate *priv = operation->priv;
+
+ if (priv->print_context)
+ {
+ g_object_unref (priv->print_context);
+ priv->print_context = NULL;
+ }
+}
+
static gboolean
custom_widget_accumulator (GSignalInvocationHint *ihint,
GValue *return_accu,
@@ -531,6 +549,7 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class)
class->preview = gtk_print_operation_preview_handler;
class->create_custom_widget = gtk_print_operation_create_custom_widget;
+ class->done = gtk_print_operation_done;
g_type_class_add_private (gobject_class, sizeof (GtkPrintOperationPrivate));
@@ -1945,7 +1964,6 @@ print_pages_idle_done (gpointer user_data)
GTK_PRINT_OPERATION_RESULT_APPLY);
g_object_unref (data->op);
-
g_free (data);
GDK_THREADS_LEAVE ();
@@ -2139,8 +2157,6 @@ print_pages_idle (gpointer user_data)
{
done = TRUE;
- g_object_ref (data->op);
-
g_signal_emit_by_name (data->op, "ready", priv->print_context);
goto out;
}
diff --git a/tests/print-editor.c b/tests/print-editor.c
index 9d6321251..445d2442c 100644
--- a/tests/print-editor.c
+++ b/tests/print-editor.c
@@ -581,7 +581,7 @@ preview_cb (GtkPrintOperation *op,
gtk_print_context_set_cairo_context (context, cr, 72, 72);
cairo_destroy (cr);
- pop->op = op;
+ pop->op = g_object_ref (op);
pop->preview = preview;
pop->spin = page;
pop->area = da;