[gtk+/gtk-3-4] file printbackend: Protect a callback by GDK_THREADS_ENTER



commit 40260587e10cf4ead97ee8ab479988e9c32d6104
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu May 17 00:11:15 2012 -0400

    file printbackend: Protect a callback by GDK_THREADS_ENTER
    
    https://bugzilla.gnome.org/show_bug.cgi?id=649569

 modules/printbackends/file/gtkprintbackendfile.c |   27 ++++++++++++++-------
 1 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/modules/printbackends/file/gtkprintbackendfile.c b/modules/printbackends/file/gtkprintbackendfile.c
index 32ce8c5..67cdbae 100644
--- a/modules/printbackends/file/gtkprintbackendfile.c
+++ b/modules/printbackends/file/gtkprintbackendfile.c
@@ -357,15 +357,14 @@ typedef struct {
   GDestroyNotify dnotify;
 } _PrintStreamData;
 
+/* expects GDK lock to be held */
 static void
-file_print_cb (GtkPrintBackendFile *print_backend,
-               GError              *error,
-               gpointer            user_data)
+file_print_cb_locked (GtkPrintBackendFile *print_backend,
+                      GError              *error,
+                      gpointer            user_data)
 {
   _PrintStreamData *ps = (_PrintStreamData *) user_data;
 
-  GDK_THREADS_ENTER ();
-
   if (ps->target_io_stream != NULL)
     g_output_stream_close (G_OUTPUT_STREAM (ps->target_io_stream), NULL, NULL);
 
@@ -380,8 +379,18 @@ file_print_cb (GtkPrintBackendFile *print_backend,
 
   if (ps->job)
     g_object_unref (ps->job);
- 
+
   g_free (ps);
+}
+
+static void
+file_print_cb (GtkPrintBackendFile *print_backend,
+               GError              *error,
+               gpointer            user_data)
+{
+  GDK_THREADS_ENTER ();
+
+  file_print_cb_locked (print_backend, error, user_data);
 
   GDK_THREADS_LEAVE ();
 }
@@ -399,7 +408,7 @@ file_write (GIOChannel   *source,
 
   error = NULL;
 
-  read_status = 
+  read_status =
     g_io_channel_read_chars (source,
                              buf,
                              _STREAM_MAX_CHUNK_SIZE,
@@ -477,8 +486,8 @@ gtk_print_backend_file_print_stream (GtkPrintBackend        *print_backend,
 error:
   if (internal_error != NULL)
     {
-      file_print_cb (GTK_PRINT_BACKEND_FILE (print_backend),
-                    internal_error, ps);
+      file_print_cb_locked (GTK_PRINT_BACKEND_FILE (print_backend),
+                            internal_error, ps);
 
       g_error_free (internal_error);
       return;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]