gtk+ r19560 - in trunk: . gtk



Author: rhult
Date: Wed Feb 13 15:36:18 2008
New Revision: 19560
URL: http://svn.gnome.org/viewvc/gtk+?rev=19560&view=rev

Log:
2008-02-13  Richard Hult  <richard imendio com>

	* gtk/gtkclipboard-quartz.c: (gtk_clipboard_wait_for_contents):
	Remove unused variables.
	(gtk_clipboard_set_contents),
	(gtk_clipboard_get_owner), (clipboard_unset),
	(gtk_clipboard_request_targets): Notify the previous clipboard
	owner when the owner changes. Fixes bug #493406.


Modified:
   trunk/ChangeLog
   trunk/gtk/gtkclipboard-quartz.c

Modified: trunk/gtk/gtkclipboard-quartz.c
==============================================================================
--- trunk/gtk/gtkclipboard-quartz.c	(original)
+++ trunk/gtk/gtkclipboard-quartz.c	Wed Feb 13 15:36:18 2008
@@ -1,7 +1,7 @@
 /* GTK - The GIMP Toolkit
  * Copyright (C) 2000 Red Hat, Inc.
  * Copyright (C) 2004 Nokia Corporation
- * Copyright (C) 2006 Imendio AB
+ * Copyright (C) 2006-2008 Imendio AB
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -94,26 +94,27 @@
   GtkSelectionData selection_data;
   guint info;
 
+  if (!clipboard->target_list)
+    return;
+
+  memset (&selection_data, 0, sizeof (GtkSelectionData));
+
   selection_data.selection = clipboard->selection;
-  selection_data.data = NULL;
   selection_data.target = _gtk_quartz_pasteboard_type_to_atom (type);
+  selection_data.display = gdk_display_get_default ();
+  selection_data.length = -1;
 
-  if (clipboard->target_list &&
-      gtk_target_list_find (clipboard->target_list, selection_data.target, &info))
+  if (gtk_target_list_find (clipboard->target_list, selection_data.target, &info))
     {
       clipboard->get_func (clipboard, &selection_data,
                            info,
                            clipboard->user_data);
-    }
-  else
-    {
-      selection_data.length = -1;
-    }
-
-  _gtk_quartz_set_selection_data_for_pasteboard (clipboard->pasteboard,
-                                                 &selection_data);
+ 
+      _gtk_quartz_set_selection_data_for_pasteboard (clipboard->pasteboard,
+                                                     &selection_data);
 
-  g_free (selection_data.data);
+      g_free (selection_data.data);
+    }
 }
 
 - (void)pasteboardChangedOwner:(NSPasteboard *)sender
@@ -393,6 +394,27 @@
 
   types = _gtk_quartz_target_entries_to_pasteboard_types (targets, n_targets);
 
+  if (!(clipboard->have_owner && have_owner) ||
+      clipboard->user_data != user_data)
+    {
+      clipboard_unset (clipboard);
+
+      if (clipboard->get_func)
+        {
+          /* Calling unset() caused the clipboard contents to be reset!
+           * Avoid leaking and return
+           */
+          if (!(clipboard->have_owner && have_owner) ||
+              clipboard->user_data != user_data)
+            {
+              (*clear_func) (clipboard, user_data);
+              return FALSE;
+            }
+          else
+            return TRUE;
+        }
+    }
+
   clipboard->user_data = user_data;
   clipboard->have_owner = have_owner;
   if (have_owner)
@@ -526,6 +548,7 @@
   
   if (old_have_owner)
     {
+      clipboard_remove_owner_notify (clipboard);
       clipboard->have_owner = FALSE;
     }
 
@@ -844,8 +867,6 @@
 				 GdkAtom       target)
 {
   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-  gchar *name;
-  NSData *data;
   GtkSelectionData *selection_data = NULL;
 
   if (target == gdk_atom_intern_static_string ("TARGETS")) 



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