The program clears my clipboard on shutdown! Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
devhobby
Earned a small fee
Earned a small fee
Posts: 13
Joined: Tue Jul 02, 2019 1:25 pm

The program clears my clipboard on shutdown!

Post by devhobby »

This is weird.

When I copy something written in the wxStyledTextCtrl and paste it somewhere else, everything is fine... but when I close the application, what I just copied from the wxStyledTextCtrl gets cleared from the clipboard!

This does not happen if I copy something from somewhere else... even after closing the application, the clipboard is intact...

Only when I copy from the wxStyledTextCtrl and close the application, what I copied disappears from the clipboard.

Does anyone of you have any idea of the reason?

Thanks in advance!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: The program clears my clipboard on shutdown!

Post by ONEEYEMAN »

Hi,
What is your wx version and under which platform you tst the application?

Can you reproduce this with the stc sample from the wxWidgets and/or with the native SciTe sample program?

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: The program clears my clipboard on shutdown!

Post by doublemax »

Use the source, Luke!
devhobby
Earned a small fee
Earned a small fee
Posts: 13
Joined: Tue Jul 02, 2019 1:25 pm

Re: The program clears my clipboard on shutdown!

Post by devhobby »

ONEEYEMAN wrote: Fri Jun 12, 2020 3:35 am What is your wx version and under which platform you tst the application?

Can you reproduce this with the stc sample from the wxWidgets and/or with the native SciTe sample program?
I'm on Windows 10, using wxWidgets version 3.1.2
doublemax wrote: Fri Jun 12, 2020 6:10 am Try wxClipboard::Flush
I tried with

Code: Select all

wxTheClipboard->Flush();
in the window constructor, but that doesn't solve the problem...

Note that I don't use any clipboard in my code, I only use a wxStyledTextCtrl so this is the only line of code about the clipboard in the code
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: The program clears my clipboard on shutdown!

Post by doublemax »

in the window constructor, but that doesn't solve the problem...
You need to call it before you exit the application. E.g. in wxApp::OnExit or the main frame dtor.

I tested this in the "stc" sample. Originally the clipboard was not persistent. After adding "wxTheClipboard->Flush();" to "App::OnExit", it was.
Use the source, Luke!
devhobby
Earned a small fee
Earned a small fee
Posts: 13
Joined: Tue Jul 02, 2019 1:25 pm

Re: The program clears my clipboard on shutdown!

Post by devhobby »

That solved the problem, thank you very much! :D
Post Reply