Copy-paste from closed editor

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.
AndrzejB
Earned some good credits
Earned some good credits
Posts: 105
Joined: Sun Nov 29, 2015 12:46 pm

Copy-paste from closed editor

Post by AndrzejB »

I have Linux Mint 20.
I open my editor, copy from, paste to other place is ok.
I open my editor, copy from, close editor, paste to other place - no paste
It is for my editor, using Scintilla or Pascal Synedit.
But - if I open Gedit, copy from, close Gedit, is OK.
Is possible paste from my closed editor like Gedit?
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Copy-paste from closed editor

Post by PB »

Do you use wxClipboard::Flush() in your code?
https://docs.wxwidgets.org/trunk/classw ... 33f291f932
AndrzejB
Earned some good credits
Earned some good credits
Posts: 105
Joined: Sun Nov 29, 2015 12:46 pm

Re: Copy-paste from closed editor

Post by AndrzejB »

I do :

Code: Select all

void MyFrame::OnCloseMain(wxCloseEvent& event)
{
    if (CloseAll()) {
        wxTheClipboard->Flush();
        Destroy();
    }
    else
        event.Veto();
}
But clipboard is cleared before destroy:, I must flush before delete notebook page.
Is problem: clibboard is cleared in wxModule::DoCleanUpModules ->
wxClipboardModule.OnExit(): wxDELETE(gs_clipboard);

Code: Select all

wxClipboard::~wxClipboard()
{
    Clear();

    gtk_widget_destroy( m_clipboardWidget ); <--------------------
    gtk_widget_destroy( m_targetsWidget );
}
Flush is only for application, not system?
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Copy-paste from closed editor

Post by PB »

Sorry, I do not use Linux myself, I am just aware of the method.

I assume you read the notes and did everything (i.e., have non-primary selection, checking the return value of Flush()).

Did you try the bundled clipboard sample and used File / Flush the Clipboard to see if it misbehaves as well on your system?
AndrzejB
Earned some good credits
Earned some good credits
Posts: 105
Joined: Sun Nov 29, 2015 12:46 pm

Re: Copy-paste from closed editor

Post by AndrzejB »

Before closing I have text "Text from wx clipboard sample at Sat Sep 26 15:16:34 2020"
but after closing - no text.
I think it is Linux behaviour Other applications like Gedit (previously I badly check it) also not copied clipboard after closing.
Partially solution - editor will opened long time with single instance with IPC.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7481
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Copy-paste from closed editor

Post by ONEEYEMAN »

Hi,
What is your version of wx?
What GTK version it is built against??
What WM are you using IGNOME, KDE, Mate, etc)?

Thank you.
AndrzejB
Earned some good credits
Earned some good credits
Posts: 105
Joined: Sun Nov 29, 2015 12:46 pm

Re: Copy-paste from closed editor

Post by AndrzejB »

I compiled wxWidgets 3.1.4 with configure:
../configure --enable-sockets --with-gtk=3 --enable-unicode --enable-debug --disable-monolithic --disable-shared
on Linux Mint 20
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7481
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Copy-paste from closed editor

Post by ONEEYEMAN »

Hi,
Can you try clipbrd sample?

Also - Flush() call is for application - it stores the data inside the clipboard somewhere for later use.

Also try to build it with:

Code: Select all

../configure --enable-debug ---with-gtk=3
Thank you.
AndrzejB
Earned some good credits
Earned some good credits
Posts: 105
Joined: Sun Nov 29, 2015 12:46 pm

Re: Copy-paste from closed editor

Post by AndrzejB »

I have cinnamon. Other applications have the same problem, including gedit and gitk.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7481
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Copy-paste from closed editor

Post by ONEEYEMAN »

Hi,
It might be native behavior then (native in terms of Window Manager).

Thank you.