Artix Linux Forum

Artix Linux => Applications & Software => Topic started by: taxol on 27 June 2021, 11:44:48

Title: [SOLVED] Clipboard emptied as soon as the original app is closed
Post by: taxol on 27 June 2021, 11:44:48
I'm a glad user of Artix LXQt and I noticed a weird bug, the clipboard is emptied as soon as I close the window from which I copied or cut from. Does anyone have an idea on how to fix that?

I have a temporary workaround, I use the CopyQ clipboard manager from the Arch repos, it stores my clipboard so that I can retrieve if I mistakenly close the window in between.

Thanks for any tips ;)
Title: Re: Clipboard emptied as soon as the original app is closed
Post by: dxrobertson on 27 June 2021, 13:46:11
The app is probably using the QT QClipboard class, which is deleted at program end.
Title: Re: Clipboard emptied as soon as the original app is closed
Post by: Kyv on 27 June 2021, 14:55:09
Installing a clipboard manager is the de-facto solution. It is going to do it's job more consistently.
Title: Re: Clipboard emptied as soon as the original app is closed
Post by: strajder on 27 June 2021, 15:11:42
https://www.jwz.org/doc/x-cut-and-paste.html
https://en.wikipedia.org/wiki/X_Window_selection
Title: Re: Clipboard emptied as soon as the original app is closed
Post by: taxol on 27 June 2021, 21:58:29
The app is probably using the QT QClipboard class, which is deleted at program end.

https://www.jwz.org/doc/x-cut-and-paste.html
https://en.wikipedia.org/wiki/X_Window_selection

Thanks for those answers that ask even more questions, I wouldn't have expected it worked like that behind the scene.

"At the level of the core protocol, the PRIMARY and CLIPBOARD selections do not differ. But the xclipboard client makes them behave differently. In particular, when another client asserts the ownership of the CLIPBOARD selection, this program requests and displays it in a window. Any further request for this selection are handled by xclipboard. This way, the content of the selection survives the client having copied it."

So xclipboard isn't the culprit but this qt class is?

Does anyone know the reasoning behing making the clipboard only survive the program from which it was filled?

What can I do apart from the clipboard manager workaround? It's kind of unconvenient still because I need to select the last element and put it again in my clipboard to get access to it, instead of just doing ctrl+v.

Thanks for any help and sorry if it's newbie level, I never tinkered with such things.
Title: Re: Clipboard emptied as soon as the original app is closed
Post by: strajder on 27 June 2021, 22:19:46
Does anyone know the reasoning behing making the clipboard only survive the program from which it was filled?

History and X Window architecture.
Title: Re: Clipboard emptied as soon as the original app is closed
Post by: dxrobertson on 27 June 2021, 22:23:17

Does anyone know the reasoning behing making the clipboard only survive the program from which it was filled?



This comes down to the QT development platform.  The  QClipboard (as well as any instantiated object) is part of the application.  And once the application ends, all its objects are disposed of.   If the QClipboard was left available, there is nothing running to manage it (dispose of it) and that would be a memory leak.  QClipboard is not meant to be a system wide, always available to everyone clipboard; thats what the  various clipboard managers that others have mentioned do.  Its more for an individual application to access the clipboard.  

Title: Re: Clipboard emptied as soon as the original app is closed
Post by: taxol on 28 June 2021, 15:38:23
Quote
and that would be a memory leak.

Makes a lot of sense. Well that was an interesting dive into the how it works. And the clipboard manager gives the functionality I expect anyway, thanks guys