Fix dodgy type-cast and init line-widths to "inherit".

Fixes https://gitlab.com/kicad/code/kicad/issues/11535
This commit is contained in:
Jeff Young 2022-05-02 22:26:55 +01:00
parent 3f470359a2
commit 67f352717e
2 changed files with 19 additions and 11 deletions

View File

@ -1476,12 +1476,10 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
int lineWidth = Mils2iu( cfg->m_Drawing.default_line_thickness );
if( isTextBox ) if( isTextBox )
item = new SCH_TEXTBOX( lineWidth, m_lastFillStyle ); item = new SCH_TEXTBOX( 0, m_lastFillStyle );
else else
item = new SCH_SHAPE( type, lineWidth, m_lastFillStyle ); item = new SCH_SHAPE( type, 0, m_lastFillStyle );
item->SetFlags( IS_NEW ); item->SetFlags( IS_NEW );
item->BeginEdit( (wxPoint) cursorPos ); item->BeginEdit( (wxPoint) cursorPos );
@ -1489,10 +1487,12 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_view->ClearPreview(); m_view->ClearPreview();
m_view->AddToPreview( item->Clone() ); m_view->AddToPreview( item->Clone() );
} }
else if( item && ( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) else if( item && ( evt->IsClick( BUT_LEFT )
|| evt->IsDblClick( BUT_LEFT )
|| evt->IsAction( &EE_ACTIONS::finishDrawing ) ) ) || evt->IsAction( &EE_ACTIONS::finishDrawing ) ) )
{ {
if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &EE_ACTIONS::finishDrawing ) if( evt->IsDblClick( BUT_LEFT )
|| evt->IsAction( &EE_ACTIONS::finishDrawing )
|| !item->ContinueEdit( (wxPoint) cursorPos ) ) || !item->ContinueEdit( (wxPoint) cursorPos ) )
{ {
item->EndEdit(); item->EndEdit();

View File

@ -636,8 +636,8 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
grid.ClearMaskFlag( GRID_HELPER::HORIZONTAL ); grid.ClearMaskFlag( GRID_HELPER::HORIZONTAL );
} }
VECTOR2I eventPosition = static_cast<VECTOR2I>( VECTOR2D eventPosition = evt->HasPosition() ? evt->Position()
evt->HasPosition() ? evt->Position() : controls->GetMousePosition() ); : controls->GetMousePosition();
VECTOR2I cursorPos = grid.BestSnapAnchor( eventPosition, LAYER_CONNECTABLE, segment ); VECTOR2I cursorPos = grid.BestSnapAnchor( eventPosition, LAYER_CONNECTABLE, segment );
controls->ForceCursorPosition( true, cursorPos ); controls->ForceCursorPosition( true, cursorPos );
@ -858,11 +858,15 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
{ {
// Coerce the line to vertical/horizontal/45 as necessary // Coerce the line to vertical/horizontal/45 as necessary
if( twoSegments && m_wires.size() >= 2 ) if( twoSegments && m_wires.size() >= 2 )
{
computeBreakPoint( { m_wires[m_wires.size() - 2], segment }, cursorPos, computeBreakPoint( { m_wires[m_wires.size() - 2], segment }, cursorPos,
currentMode ); currentMode );
}
else else
{
segment->SetEndPoint( cursorPos ); segment->SetEndPoint( cursorPos );
} }
}
for( SCH_LINE* wire : m_wires ) for( SCH_LINE* wire : m_wires )
{ {
@ -886,10 +890,14 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
// Find new bend point for current mode // Find new bend point for current mode
if( twoSegments && m_wires.size() >= 2 ) if( twoSegments && m_wires.size() >= 2 )
{
computeBreakPoint( { m_wires[m_wires.size() - 2], segment }, cursorPos, computeBreakPoint( { m_wires[m_wires.size() - 2], segment }, cursorPos,
currentMode ); currentMode );
}
else else
{
segment->SetEndPoint( cursorPos ); segment->SetEndPoint( cursorPos );
}
for( SCH_LINE* wire : m_wires ) for( SCH_LINE* wire : m_wires )
{ {