Bug 409366 - Clearing clipboard history does not clear the clipboard
Summary: Clearing clipboard history does not clear the clipboard
Status: RESOLVED FIXED
Alias: None
Product: klipper
Classification: Applications
Component: plasma-widget (show other bugs)
Version: 5.16.3
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: phd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-01 12:51 UTC by ultr
Modified: 2019-12-16 22:59 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.18.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ultr 2019-07-01 12:51:02 UTC
SUMMARY
Clearing clipboard history does not clear the clipboard content.

STEPS TO REPRODUCE
0. Open Kate, input some text.
1. Copy the text into clipboard.
2. Clear the Plasma's clipboard.
3. Try pasting the clipboard content into Kate (it will paste).
OR
0. Open Dolphin, select a file.
1. Copy the file.
2. Clear the Plasma's clipboard.
3. Open context menu in Dolphin, notice you can still "Paste One File".

OBSERVED RESULT
*History* is cleared, there is no active element in the Plasma widget.
Clipboard's *tooltip* says that "the clipboard is empty".
But pressing Ctrl+V pastes the last clipboard content!

EXPECTED RESULT
Clipboard should actually be cleared.

This worked fine in 5.15.x (and maybe also in 5.16.0/5.16.1).

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.16.2
KDE Frameworks Version: 5.59.0
Qt Version: 5.12.2

Marking as Major due to possible privacy/security issues while Plasma show misleading messages.
Comment 1 Kai Uwe Broulik 2019-07-01 12:53:08 UTC
Uncheck "Prevent empty clipboard" in settings
Comment 2 ultr 2019-07-01 13:28:39 UTC
Update:

It seems to be X11-wide problem.

$ xsel -bc
should clean the clipboard, but doesn't.

A workaround could be to set the clipboard to an empty string:
$ true | xclip -selection clipboard
and only then clean the Klipper's history.

SOFTWARE/OS VERSIONS
OS: Ubuntu 19.04
X.Org: 1.20.4
Comment 3 ultr 2019-07-01 13:35:28 UTC
@Kai Uwe Broulik

I had this option unchecked.

But after:
- checking it
- pressing Apply
- unchecking it
- applying the settings again
the issue does no longer occur.

Weird. Closing the bug.
Comment 4 ultr 2019-07-02 21:38:09 UTC
With "Prevent empty clipboard" option unchecked Klipper fails to work properly.
So the original issue still stands (or this is an entirely new problem with Klipper).

Issue when "Prevent empty clipboard" option is unchecked:

SUMMARY
Content of clipboard is lost after closing application.

STEPS TO REPRODUCE
0. Uncheck "Prevent empty clipboard" option in Klipper.
1. Open 2 instances of KWrite (or Kate).
2. Input some text into one KWrite window.
3. Copy this text.
4. Close the window (without saving).
5. Try pasting the text into another KWrite window (it won't work).

OBSERVED RESULT
Cannot paste text copied a moment ago.
Plasma's Klipper widget shows the copied text in the history,
but it is not in the clipboard (use `xsel -o` to verify this).

EXPECTED RESULT
Clipboard should contain the copied text.
It should not be emptied after closing application window.

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.16.2
KDE Frameworks Version: 5.59.0
Qt Version: 5.12.2
Comment 5 ultr 2019-07-09 16:44:58 UTC
The original issue was most likely caused by this change:

https://github.com/KDE/plasma-workspace/commit/3bd6ac34ed74e3b86bfb6b29818b726baf505f20#diff-4aebb4a49ac5fcac58f31c1db689096e

>[Klipper] Always restore the last clipbboard item
>Summary:
>D19852 intrdouced x-kde-force-image-copy hint for programs to specify that
>images should be set to the clipboard even if should not be included in the
>history. But when the program was closed the clipboard was restored to the first
>item in history in which the image was not included. To fix this introduce a new
>class member which holds the last clipboard item and restore it.
>Credit goes to David Edumndson
>Test Plan:
>Try it with spectacle

It is fine, but simply lacks support for clearing the history for the new m_last variable breaking the previous behavior in this matter.
Comment 6 ultr 2019-07-16 14:17:41 UTC
The original issue still occurs in Plasma 5.16.3.
Comment 7 ultr 2019-07-23 14:02:28 UTC
Fix: https://phabricator.kde.org/D22684
Comment 8 Nate Graham 2019-12-16 22:58:34 UTC
Git commit 423308f854c4b76c72da4e3263614c7b20642ebf by Nate Graham, on behalf of Piotr Henryk Dabrowski.
Committed on 16/12/2019 at 22:58.
Pushed by ngraham into branch 'master'.

[Klipper] Fix clipboard history management

Summary:
Fixed clearing the clipboard when clearing history
(bug #409366 caused by 3bd6ac34ed74e3b86bfb6b29818b726baf505f20)

Properly synchronize clipboard content and history
(deleting last item in history didn't clear the clipboard).

Keep last image in history even if we are ignoring images, but without preview
(so that we can still clear history, and the tooltip says truth about clipboard content).

Fixed tray icon tooltip text.

Do not scale small images up in clipboard Plasmoid.

{F7168503}

Test Plan:
Spectacle -> [Copy to Clipboard]
Paste into Dolphin (clipboard content)

Deleting single items from clipboard

Clearing the entire history

Reviewers: #plasma, #plasma_workspaces, ngraham, davidedmundson

Reviewed By: #plasma, #plasma_workspaces, ngraham, davidedmundson

Subscribers: GB_2, davidre, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D22684

M  +1    -1    applets/clipboard/contents/ui/ClipboardPage.qml
M  +2    -1    applets/clipboard/contents/ui/ImageItemDelegate.qml
M  +2    -0    klipper/autotests/CMakeLists.txt
M  +23   -7    klipper/historyimageitem.cpp
M  +1    -1    klipper/historyimageitem.h
M  +2    -2    klipper/historyitem.cpp
M  +4    -1    klipper/historyitem.h
M  +1    -0    klipper/historymodel.cpp
M  +12   -0    klipper/historymodel.h
M  +23   -14   klipper/klipper.cpp
M  +2    -2    klipper/klipper.h

https://commits.kde.org/plasma-workspace/423308f854c4b76c72da4e3263614c7b20642ebf