After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 557315 - stale clipboard target cache
stale clipboard target cache
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.12.x
Other Linux
: Normal minor
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2008-10-21 20:54 UTC by Evan Stade
Modified: 2008-10-26 01:32 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22



Description Evan Stade 2008-10-21 20:54:45 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.
Comment 1 Evan Stade 2008-10-21 21:29:35 UTC
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.
Comment 2 Matthias Clasen 2008-10-26 01:32:31 UTC
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