Add paste length control to PCB Editor as well

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20732
This commit is contained in:
Seth Hillbrand 2025-04-30 13:25:56 -07:00
parent c5fde2aeb5
commit fd0b8fcc3c
2 changed files with 11 additions and 1 deletions

View File

@ -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<size_t>( 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 );
}

View File

@ -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<size_t>( 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<PCB_TEXT> item = std::make_unique<PCB_TEXT>( m_frame->GetModel() );
item->SetText( clipText );