[klipper] A better fix for BUG 431673 + fix memory leaks
This MR does the following:
- better fixes the BUG 431673
- fixes memory leaks caused by incorrect use of HistoryItem::mimeData()
- slightly improves the code
Edited by Eugene Popov
This MR does the following: