diff options
author | Richard Hult <richard@imendio.com> | 2008-02-13 15:36:18 +0000 |
---|---|---|
committer | Richard Hult <rhult@src.gnome.org> | 2008-02-13 15:36:18 +0000 |
commit | fce8ef214ea7b11590788e17f9ba71f7e0b6aba5 (patch) | |
tree | 0f9f937195d838b9d0fac16417ee9ccdfacf73ea /gtk/gtkclipboard-quartz.c | |
parent | 24d682c1dba1e2adfed4f1152eba03b25a672b64 (diff) | |
download | gtk+-fce8ef214ea7b11590788e17f9ba71f7e0b6aba5.tar.gz |
Remove unused variables. (gtk_clipboard_set_contents),
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.
svn path=/trunk/; revision=19560
Diffstat (limited to 'gtk/gtkclipboard-quartz.c')
-rw-r--r-- | gtk/gtkclipboard-quartz.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/gtk/gtkclipboard-quartz.c b/gtk/gtkclipboard-quartz.c index 3e53f3dd6c..6312e391b7 100644 --- a/gtk/gtkclipboard-quartz.c +++ b/gtk/gtkclipboard-quartz.c @@ -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 @@ struct _GtkClipboardClass 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 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard, 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 @@ clipboard_unset (GtkClipboard *clipboard) if (old_have_owner) { + clipboard_remove_owner_notify (clipboard); clipboard->have_owner = FALSE; } @@ -844,8 +867,6 @@ gtk_clipboard_wait_for_contents (GtkClipboard *clipboard, GdkAtom target) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - gchar *name; - NSData *data; GtkSelectionData *selection_data = NULL; if (target == gdk_atom_intern_static_string ("TARGETS")) |