From fce8ef214ea7b11590788e17f9ba71f7e0b6aba5 Mon Sep 17 00:00:00 2001 From: Richard Hult Date: Wed, 13 Feb 2008 15:36:18 +0000 Subject: [PATCH] Remove unused variables. (gtk_clipboard_set_contents), 2008-02-13 Richard Hult * 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 --- ChangeLog | 9 +++++++ gtk/gtkclipboard-quartz.c | 55 +++++++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index d208e845ff..ab88ec308e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-02-13 Richard Hult + + * 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. + 2008-02-13 Richard Hult * gdk/quartz/gdkcolor-quartz.c: (gdk_colormap_alloc_colors): Fix 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; - selection_data.selection = clipboard->selection; - selection_data.data = NULL; - selection_data.target = _gtk_quartz_pasteboard_type_to_atom (type); + if (!clipboard->target_list) + return; - if (clipboard->target_list && - gtk_target_list_find (clipboard->target_list, selection_data.target, &info)) + memset (&selection_data, 0, sizeof (GtkSelectionData)); + + selection_data.selection = clipboard->selection; + selection_data.target = _gtk_quartz_pasteboard_type_to_atom (type); + selection_data.display = gdk_display_get_default (); + selection_data.length = -1; + + 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"))