From ae009e075868c9ecdbf76eac7b4b7abf03ae9c10 Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Sat, 1 May 2021 23:00:08 +0100 Subject: [PATCH] Ensure clipboard data is available after KiCad closes Always Flush() after SetData() --- bitmap2component/bitmap2cmp_gui.cpp | 1 + common/dialogs/html_messagebox.cpp | 1 + common/dialogs/wx_html_report_panel.cpp | 1 + common/grid_tricks.cpp | 1 + common/tool/tool_manager.cpp | 2 ++ eeschema/dialogs/dialog_choose_symbol.cpp | 1 + eeschema/sheet.cpp | 1 + pcbnew/board_stackup_manager/panel_board_stackup.cpp | 1 + qa/pns/pns_log_viewer.cpp | 1 + 9 files changed, 10 insertions(+) diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp index 12eafa8144..2ec9ee67ef 100644 --- a/bitmap2component/bitmap2cmp_gui.cpp +++ b/bitmap2component/bitmap2cmp_gui.cpp @@ -696,6 +696,7 @@ void BM2CMP_FRAME::OnExportToClipboard( wxCommandEvent& event ) // This data objects are held by the clipboard, // so do not delete them in the app. wxTheClipboard->SetData( new wxTextDataObject( buffer.c_str() ) ); + wxTheClipboard->Flush(); // Allow data to be available after closing KiCad wxTheClipboard->Close(); } else diff --git a/common/dialogs/html_messagebox.cpp b/common/dialogs/html_messagebox.cpp index dea2e77a23..7b9480f3e6 100644 --- a/common/dialogs/html_messagebox.cpp +++ b/common/dialogs/html_messagebox.cpp @@ -150,6 +150,7 @@ void HTML_MESSAGE_BOX::OnCharHook( wxKeyEvent& aEvent ) if( wxTheClipboard->Open() ) { wxTheClipboard->SetData( new wxTextDataObject( m_htmlWindow->SelectionToText() ) ); + wxTheClipboard->Flush(); // Allow data to be available after closing KiCad wxTheClipboard->Close(); } diff --git a/common/dialogs/wx_html_report_panel.cpp b/common/dialogs/wx_html_report_panel.cpp index b9e005c9f6..c654c768a4 100644 --- a/common/dialogs/wx_html_report_panel.cpp +++ b/common/dialogs/wx_html_report_panel.cpp @@ -236,6 +236,7 @@ void WX_HTML_REPORT_PANEL::onMenuEvent( wxMenuEvent& event ) bool primarySelection = wxTheClipboard->IsUsingPrimarySelection(); wxTheClipboard->UsePrimarySelection( false ); // required to use the main clipboard wxTheClipboard->SetData( new wxTextDataObject( m_htmlView->SelectionToText() ) ); + wxTheClipboard->Flush(); // Allow data to be available after closing KiCad wxTheClipboard->Close(); wxTheClipboard->UsePrimarySelection( primarySelection ); } diff --git a/common/grid_tricks.cpp b/common/grid_tricks.cpp index d0dfcc2174..d8c4ac0e10 100644 --- a/common/grid_tricks.cpp +++ b/common/grid_tricks.cpp @@ -636,6 +636,7 @@ void GRID_TRICKS::cutcopy( bool doCopy, bool doDelete ) if( doCopy ) { wxTheClipboard->SetData( new wxTextDataObject( txt ) ); + wxTheClipboard->Flush(); // Allow data to be available after closing KiCad wxTheClipboard->Close(); } diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 191fb1b763..d88a1aa24a 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -980,6 +980,8 @@ bool TOOL_MANAGER::SaveClipboard( const std::string& aTextUTF8 ) // Store the UTF8 string as unicode string in clipboard: wxTheClipboard->SetData( new wxTextDataObject( wxString( aTextUTF8.c_str(), wxConvUTF8 ) ) ); + + wxTheClipboard->Flush(); // Allow data to be available after closing KiCad wxTheClipboard->Close(); return true; diff --git a/eeschema/dialogs/dialog_choose_symbol.cpp b/eeschema/dialogs/dialog_choose_symbol.cpp index 5ef47004f0..07f9443958 100644 --- a/eeschema/dialogs/dialog_choose_symbol.cpp +++ b/eeschema/dialogs/dialog_choose_symbol.cpp @@ -332,6 +332,7 @@ void DIALOG_CHOOSE_SYMBOL::OnCharHook( wxKeyEvent& e ) if( wxTheClipboard->Open() ) { wxTheClipboard->SetData( new wxTextDataObject( txt ) ); + wxTheClipboard->Flush(); // Allow data to be available after closing KiCad wxTheClipboard->Close(); } } diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 4d3c64a955..21dc0ff46d 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -541,6 +541,7 @@ void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard() // This data objects are held by the clipboard, so do not delete them in the app. wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image ); wxTheClipboard->SetData( clipbrd_data ); + wxTheClipboard->Flush(); // Allow data to be available after closing KiCad wxTheClipboard->Close(); } } diff --git a/pcbnew/board_stackup_manager/panel_board_stackup.cpp b/pcbnew/board_stackup_manager/panel_board_stackup.cpp index 7ce18e45b6..d9f5aeaa5e 100644 --- a/pcbnew/board_stackup_manager/panel_board_stackup.cpp +++ b/pcbnew/board_stackup_manager/panel_board_stackup.cpp @@ -299,6 +299,7 @@ void PANEL_SETUP_BOARD_STACKUP::onExportToClipboard( wxCommandEvent& event ) // This data objects are held by the clipboard, // so do not delete them in the app. wxTheClipboard->SetData( new wxTextDataObject( report ) ); + wxTheClipboard->Flush(); // Allow data to be available after closing KiCad wxTheClipboard->Close(); } } diff --git a/qa/pns/pns_log_viewer.cpp b/qa/pns/pns_log_viewer.cpp index 7703495f29..491377de27 100644 --- a/qa/pns/pns_log_viewer.cpp +++ b/qa/pns/pns_log_viewer.cpp @@ -510,6 +510,7 @@ void PNS_LOG_VIEWER_FRAME::onListCopy( wxCommandEvent& event ) // This data objects are held by the clipboard, // so do not delete them in the app. wxTheClipboard->SetData( new wxTextDataObject(s) ); + wxTheClipboard->Flush(); // Allow data to be available after closing KiCad wxTheClipboard->Close(); } }