From 0ec3720ee5baa38536f09c96d35ef29cd3bfae29 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 1 Dec 2024 18:56:52 +0000 Subject: [PATCH] Don't hang when trying to paste image as text. Fixes https://gitlab.com/kicad/code/kicad/-/issues/19079 (cherry picked from commit 5caaf22949448e89ba6a70f7bb6af27425a5d0f4) --- eeschema/tools/symbol_editor_edit_tool.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/eeschema/tools/symbol_editor_edit_tool.cpp b/eeschema/tools/symbol_editor_edit_tool.cpp index c35406b44c..f3b38e3542 100644 --- a/eeschema/tools/symbol_editor_edit_tool.cpp +++ b/eeschema/tools/symbol_editor_edit_tool.cpp @@ -818,8 +818,16 @@ int SYMBOL_EDITOR_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent ) { // If it's not a symbol then paste as text newPart = new LIB_SYMBOL( "dummy_part" ); + + wxString pasteText( clipboardData ); + + // Limit of 5000 is totally arbitrary. Without a limit, pasting a bitmap image from + // eeschema makes KiCad appear to hang. + if( pasteText.Length() > 5000 ) + pasteText = pasteText.Left( 5000 ) + wxT( "..." ); + LIB_TEXT* newText = new LIB_TEXT( newPart ); - newText->SetText( clipboardData ); + newText->SetText( pasteText ); newPart->AddDrawItem( newText ); }