GNOME Bugzilla – Bug 790344
gsd-clipboard stops saving the clipboard if it gets an error from a MULTIPLE request
Last modified: 2017-11-21 18:14:58 UTC
Created attachment 363639 [details] [review] Patch for the bug Here's how you can reproduce this: 1) Install Tcl/Tk <= 8.6.7 (note: this reproduction recipe depends on a bug in Tk that's likely to be fixed in the next release of Tk; see https://core.tcl.tk/tk/tktview/73ba07efcd3834adcebed93f2a3d289ebc2369ea). 2) Make sure gsd-clipboard is running. 3) Run the following script using wish: proc get_clip {offset maxChars} { return abcd } selection handle -selection CLIPBOARD . get_clip selection own -selection CLIPBOARD . selection get -selection CLIPBOARD_MANAGER -type SAVE_TARGETS exit It will print an error due to the aforementioned bug. 4) Run Gedit. Type something in, copy it to the clipboard. Close gedit. 5) Paste to the terminal. Nothing will get pasted. Expected behavior: the stuff you copied in Gedit should get pasted. I'm attaching a patch that fixes this (+ a refactoring patch). There's an explanation in the commit message.
Comment on attachment 363639 [details] [review] Patch for the bug Hold on, I'll reattach the patches separately.
Created attachment 363863 [details] [review] clipboard: factor out the freeing of priv->contents into a function
Created attachment 363864 [details] [review] clipboard: add a missing free_contents Currently, when gsd-clipboard receives a response to a conversion request for the MULTIPLE target that indicates failure (i.e. property == None), it doesn't free the contents list. This leads it to believe it owns the CLIPBOARD selection, when it actually doesn't. Because of this, it returns an error for all subsequent SAVE_TARGETS requests, effectively becoming inoperative as a clipboard manager. So fix that. Because of the way the code is structured, free_contents will also be called when a request for the TARGETS target fails, but at that point the contents list should be empty, so it'll be harmless.
Review of attachment 363863 [details] [review]: sure
Review of attachment 363864 [details] [review]: makes sense, thanks for the patches
Attachment 363863 [details] pushed as e9a89d6 - clipboard: factor out the freeing of priv->contents into a function Attachment 363864 [details] pushed as 776bb25 - clipboard: add a missing free_contents