From fd0b8fcc3ce2af415f28ea75381c27d37235b569 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 30 Apr 2025 13:25:56 -0700 Subject: [PATCH] Add paste length control to PCB Editor as well Fixes https://gitlab.com/kicad/code/kicad/-/issues/20732 --- eeschema/tools/sch_editor_control.cpp | 3 ++- pcbnew/tools/pcb_control.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index c987ecabbc..c8ba4bd036 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -1714,13 +1714,14 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent ) catch( IO_ERROR& ) { // If it wasn't content, then paste as a text object. - if( content.size() > ADVANCED_CFG::GetCfg().m_MaxPastedTextLength ) + if( content.size() > static_cast( ADVANCED_CFG::GetCfg().m_MaxPastedTextLength ) ) { int result = IsOK( m_frame, _( "Pasting a long text text string may be very slow. " "Do you want to continue?" ) ); if( !result ) return 0; } + SCH_TEXT* text_item = new SCH_TEXT( VECTOR2I( 0, 0 ), content ); tempScreen->Append( text_item ); } diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index 1fbc2ba4e1..3a4f5d6aa6 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -1088,6 +1088,15 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent ) if( clipText.empty() ) return 0; + // If it wasn't content, then paste as a text object. + if( clipText.size() > static_cast( ADVANCED_CFG::GetCfg().m_MaxPastedTextLength ) ) + { + int result = IsOK( m_frame, _( "Pasting a long text text string may be very slow. " + "Do you want to continue?" ) ); + if( !result ) + return 0; + } + std::unique_ptr item = std::make_unique( m_frame->GetModel() ); item->SetText( clipText );