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 790344 - gsd-clipboard stops saving the clipboard if it gets an error from a MULTIPLE request
gsd-clipboard stops saving the clipboard if it gets an error from a MULTIPLE ...
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: plugins
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2017-11-14 20:40 UTC by Роман Донченко
Modified: 2017-11-21 18:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for the bug (5.31 KB, patch)
2017-11-14 20:40 UTC, Роман Донченко
none Details | Review
clipboard: factor out the freeing of priv->contents into a function (3.61 KB, patch)
2017-11-16 18:54 UTC, Роман Донченко
committed Details | Review
clipboard: add a missing free_contents (1.78 KB, patch)
2017-11-16 18:54 UTC, Роман Донченко
committed Details | Review

Description Роман Донченко 2017-11-14 20:40:48 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 1 Роман Донченко 2017-11-16 18:53:43 UTC
Comment on attachment 363639 [details] [review]
Patch for the bug

Hold on, I'll reattach the patches separately.
Comment 2 Роман Донченко 2017-11-16 18:54:52 UTC
Created attachment 363863 [details] [review]
clipboard: factor out the freeing of priv->contents into a function
Comment 3 Роман Донченко 2017-11-16 18:54:57 UTC
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.
Comment 4 Rui Matos 2017-11-21 17:58:01 UTC
Review of attachment 363863 [details] [review]:

sure
Comment 5 Rui Matos 2017-11-21 18:03:11 UTC
Review of attachment 363864 [details] [review]:

makes sense, thanks for the patches
Comment 6 Rui Matos 2017-11-21 18:14:51 UTC
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