Bug 343333

Summary: plasmashell crash overwrites current clipboard with old data
Product: [Applications] klipper Reporter: Eike Hein <hein>
Component: generalAssignee: Martin Flöser <mgraesslin>
Status: RESOLVED FIXED    
Severity: normal CC: BryanFRitt, piomar123
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.3.0

Description Eike Hein 2015-01-26 14:44:31 UTC
This is a common occurence currently:

1. Copy something to the clipboard.
2. plasmashell crashes and comes back.
3. Pasting now will paste very old data from the clipboard history.

This is unexpected behavior, because from the user's POV, the clipboard is global and not a function of the Plasma Desktop chrome. The clipboard mediates between applications, and since those stay running and visible, there's no reasonable connection to make between plasmashell flickering out of existence and back and clipboard data being replaced. I would not expect users to be understanding or caring about the implementation details involved.

It's also a data loss problem: If the previous clipboard contents were the only copy of the data, it's now gone.

There seem to be two ways to address this, possibly complimentary:

- Move the clipboard history back out of the plasmashell process as it was done in KDE 4. It really has no place being there (see above) and process separation for these distinct features would be a much more resilient design.

- Make Klipper serialize the history to persistent storage immediately instead of just at plasmashell exit.

Reproducible: Always
Comment 1 Martin Flöser 2015-02-02 15:14:47 UTC
approach 2: https://git.reviewboard.kde.org/r/122382/
Comment 2 Martin Flöser 2015-02-19 13:09:42 UTC
Git commit 9e69e845044bb07c7aef4831e05c45cba68ac1d1 by Martin Gräßlin.
Committed on 02/02/2015 at 15:05.
Pushed by graesslin into branch 'master'.

[klipper] Sync history to disk after each change

By invoking saveHistory after each change we ensure that the clipboard
doesn't lose data in case klipper (or in dataengine mode plasmashell)
crashes.

To not cause stalls, the saving is performed in a thread using
QtConcurrentRun. As klipper itself is not thread save a Mutex is
used to lock changes in the HistoryModel.

To not overload the system the save operations are delayed and queued.
Each save is delayed by five seconds since the last clipboard change.
So if the clipboard is changed multiple times in a short interval it
doesn't get synced to the disk till the interaction has settled.
FIXED-IN: 5.3.0
REVIEW: 122382

M  +1    -0    klipper/CMakeLists.txt
M  +7    -0    klipper/historymodel.cpp
M  +6    -0    klipper/historymodel.h
M  +18   -0    klipper/klipper.cpp
M  +1    -0    klipper/klipper.h

http://commits.kde.org/plasma-workspace/9e69e845044bb07c7aef4831e05c45cba68ac1d1
Comment 3 Martin Flöser 2015-10-20 12:38:30 UTC
*** Bug 354125 has been marked as a duplicate of this bug. ***
Comment 4 Martin Flöser 2017-02-12 19:39:17 UTC
*** Bug 376408 has been marked as a duplicate of this bug. ***