GNOME Bugzilla – Bug 557315
stale clipboard target cache
Last modified: 2008-10-26 01:32:31 UTC
Please describe the problem: The gtk clipboard caches the targets and only renews the cache when the owner changes. The cache should also be renewed when gtk_clipboard_set_contents is called. Steps to reproduce: On the default clipboard (GDK_SELECTION_CLIPBOARD), 1. Call gtk_clipboard_set_with_data 2. Call it again (different target list) 3. Examine available targets with gtk_clipboard_wait_for_targets Actual results: The target list that is returned is the target list set during the first call to set_with_data. Expected results: The target list that is returned is the target list set during the second call to set_with_data. Does this happen every time? Yes. Other information: If you manually examine the contents of the "TARGETS" target (via gtk_clipboard_wait_for_contents followed by gtk_selection_data_get_targets) then the correct targets are returned. Only the targets cache in the _GtkClipboard struct is wrong.
I believe this is a 2 line fix. Add clipboard->n_cached_targets = -1; g_free (clipboard->cached_targets); somewhere in gtk_clipboard_set_contents. It might also be necessary to set cached_targets to NULL at some points to prevent double freeing.
2008-10-25 Matthias Clasen <mclasen@redhat.com> Bug 557315 – stale clipboard target cache * gtk/gtkclipboard.c (gtk_clipboard_set_contents): Remove cached targets. Pointed out by Evan Stade