]> Pileus Git - ~andy/gtk/commitdiff
Make the clipboard image API more robust (#162357, Torsten Schoenfeld):
authorMatthias Clasen <mclasen@redhat.com>
Tue, 28 Dec 2004 04:31:40 +0000 (04:31 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Tue, 28 Dec 2004 04:31:40 +0000 (04:31 +0000)
2004-12-27  Matthias Clasen  <mclasen@redhat.com>

Make the clipboard image API more robust (#162357,
Torsten Schoenfeld):

* gtk/gtkclipboard.c (clipboard_image_received_func): Don't
ref the pixbuf if it is NULL.

* gtk/gtkselection.c (gtk_selection_data_set_pixbuf):
NULL-terminate the varargs in the call to
gdk_pixbuf_save_to_buffer().
(gtk_selection_data_get_pixbuf): Only use a pixbuf loader
if there is data to load.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkclipboard.c
gtk/gtkselection.c

index 522a7a26f1fe76ba011d24e1b4715385baf20cdb..faf595caf209d1f2cbd0306b94b494d6e377899e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2004-12-27  Matthias Clasen  <mclasen@redhat.com>
+
+       Make the clipboard image API more robust (#162357, 
+       Torsten Schoenfeld):
+       
+       * gtk/gtkclipboard.c (clipboard_image_received_func): Don't
+       ref the pixbuf if it is NULL.
+
+       * gtk/gtkselection.c (gtk_selection_data_set_pixbuf): 
+       NULL-terminate the varargs in the call to 
+       gdk_pixbuf_save_to_buffer(). 
+       (gtk_selection_data_get_pixbuf): Only use a pixbuf loader 
+       if there is data to load.
+
 2004-12-27  Matthias Clasen  <mclasen@redhat.com>
 
        * gdk/x11/gdkinput-x11.c (_gdk_input_common_other_event): 
index 522a7a26f1fe76ba011d24e1b4715385baf20cdb..faf595caf209d1f2cbd0306b94b494d6e377899e 100644 (file)
@@ -1,3 +1,17 @@
+2004-12-27  Matthias Clasen  <mclasen@redhat.com>
+
+       Make the clipboard image API more robust (#162357, 
+       Torsten Schoenfeld):
+       
+       * gtk/gtkclipboard.c (clipboard_image_received_func): Don't
+       ref the pixbuf if it is NULL.
+
+       * gtk/gtkselection.c (gtk_selection_data_set_pixbuf): 
+       NULL-terminate the varargs in the call to 
+       gdk_pixbuf_save_to_buffer(). 
+       (gtk_selection_data_get_pixbuf): Only use a pixbuf loader 
+       if there is data to load.
+
 2004-12-27  Matthias Clasen  <mclasen@redhat.com>
 
        * gdk/x11/gdkinput-x11.c (_gdk_input_common_other_event): 
index 522a7a26f1fe76ba011d24e1b4715385baf20cdb..faf595caf209d1f2cbd0306b94b494d6e377899e 100644 (file)
@@ -1,3 +1,17 @@
+2004-12-27  Matthias Clasen  <mclasen@redhat.com>
+
+       Make the clipboard image API more robust (#162357, 
+       Torsten Schoenfeld):
+       
+       * gtk/gtkclipboard.c (clipboard_image_received_func): Don't
+       ref the pixbuf if it is NULL.
+
+       * gtk/gtkselection.c (gtk_selection_data_set_pixbuf): 
+       NULL-terminate the varargs in the call to 
+       gdk_pixbuf_save_to_buffer(). 
+       (gtk_selection_data_get_pixbuf): Only use a pixbuf loader 
+       if there is data to load.
+
 2004-12-27  Matthias Clasen  <mclasen@redhat.com>
 
        * gdk/x11/gdkinput-x11.c (_gdk_input_common_other_event): 
index 522a7a26f1fe76ba011d24e1b4715385baf20cdb..faf595caf209d1f2cbd0306b94b494d6e377899e 100644 (file)
@@ -1,3 +1,17 @@
+2004-12-27  Matthias Clasen  <mclasen@redhat.com>
+
+       Make the clipboard image API more robust (#162357, 
+       Torsten Schoenfeld):
+       
+       * gtk/gtkclipboard.c (clipboard_image_received_func): Don't
+       ref the pixbuf if it is NULL.
+
+       * gtk/gtkselection.c (gtk_selection_data_set_pixbuf): 
+       NULL-terminate the varargs in the call to 
+       gdk_pixbuf_save_to_buffer(). 
+       (gtk_selection_data_get_pixbuf): Only use a pixbuf loader 
+       if there is data to load.
+
 2004-12-27  Matthias Clasen  <mclasen@redhat.com>
 
        * gdk/x11/gdkinput-x11.c (_gdk_input_common_other_event): 
index 150e801a252848e4c5a13c35d0546cb791538b29..bf88e8de7a173a814838382a61b79fe685c52188 100644 (file)
@@ -1245,7 +1245,9 @@ clipboard_image_received_func (GtkClipboard *clipboard,
 {
   WaitResults *results = data;
 
-  results->data = g_object_ref (pixbuf);
+  if (pixbuf)
+    results->data = g_object_ref (pixbuf);
+
   g_main_loop_quit (results->loop);
 }
 
index d3f963dfe328ef7c679b88c29c4d50c78c6d4952..1d147b9976bab77cf3236cc32fcfcd2eddc4d7a7 100644 (file)
@@ -1266,11 +1266,8 @@ gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data,
            {
              str = NULL;
              type = gdk_pixbuf_format_get_name (fmt),
-             result = gdk_pixbuf_save_to_buffer (pixbuf,
-                                                 &str,
-                                                 &len,
-                                                 type,
-                                                 NULL);
+             result = gdk_pixbuf_save_to_buffer (pixbuf, &str, &len,
+                                                 type, NULL, NULL);
              if (result) 
                gtk_selection_data_set (selection_data,
                                        atom, 8, (guchar *)str, len);
@@ -1310,20 +1307,23 @@ gtk_selection_data_get_pixbuf (GtkSelectionData *selection_data)
   GdkPixbufLoader *loader;
   GdkPixbuf *result = NULL;
 
-  loader = gdk_pixbuf_loader_new ();
-  
-  if (gdk_pixbuf_loader_write (loader, 
-                              selection_data->data,
-                              selection_data->length,
-                              NULL))
-    result = gdk_pixbuf_loader_get_pixbuf (loader);
-  
-  if (result)
-    g_object_ref (result);
+  if (selection_data->length > 0)
+    {
+      loader = gdk_pixbuf_loader_new ();
+      
+      if (gdk_pixbuf_loader_write (loader, 
+                                  selection_data->data,
+                                  selection_data->length,
+                                  NULL))
+       result = gdk_pixbuf_loader_get_pixbuf (loader);
+      
+      if (result)
+       g_object_ref (result);
+      
+      gdk_pixbuf_loader_close (loader, NULL);
+      g_object_unref (loader);
+    }
 
-  gdk_pixbuf_loader_close (loader, NULL);
-  g_object_unref (loader);
-  
   return result;
 }