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
This commit is contained in:
Matthias Clasen
2007-04-30 04:50:49 +00:00
committed by Matthias Clasen
parent 08bf8df1a0
commit e23495daee
3 changed files with 39 additions and 4 deletions

View File

@@ -1,3 +1,22 @@
2007-04-29 Matthias Clasen <mclasen@redhat.com>
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:

View File

@@ -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;
}

View File

@@ -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;