Fix bug in JunctionNeeded and selection around adding/removing junctions.

When checking for 3 or more connections, at least one of them must be
a pin.  Otherwise we need to fall down to the next check which also
ensures that at least one of them is not parallel.

Fixes: lp:1841458
* https://bugs.launchpad.net/kicad/+bug/1841458
This commit is contained in:
Jeff Young 2019-09-12 20:08:35 +01:00
parent f204208667
commit 7ad98b8a7d
2 changed files with 25 additions and 3 deletions

View File

@ -138,6 +138,7 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( SCH_SCREEN* aScreen )
SCH_ITEM* item = NULL; SCH_ITEM* item = NULL;
SCH_ITEM* secondItem = NULL; SCH_ITEM* secondItem = NULL;
PICKED_ITEMS_LIST itemList; PICKED_ITEMS_LIST itemList;
EE_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
if( aScreen == nullptr ) if( aScreen == nullptr )
aScreen = GetScreen(); aScreen = GetScreen();
@ -215,7 +216,12 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( SCH_SCREEN* aScreen )
remove_item( item ); remove_item( item );
remove_item( secondItem ); remove_item( secondItem );
itemList.PushItem( ITEM_PICKER( line, UR_NEW ) ); itemList.PushItem( ITEM_PICKER( line, UR_NEW ) );
AddToScreen( line, aScreen ); AddToScreen( line, aScreen );
if( line->IsSelected() )
selectionTool->AddItemToSel( line, true /*quiet mode*/ );
break; break;
} }
} }
@ -230,7 +236,12 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( SCH_SCREEN* aScreen )
secondItem = item->Next(); secondItem = item->Next();
if( item->GetEditFlags() & STRUCT_DELETED ) if( item->GetEditFlags() & STRUCT_DELETED )
{
if( item->IsSelected() )
selectionTool->RemoveItemFromSel( item, true /*quiet mode*/ );
RemoveFromScreen( item, aScreen ); RemoveFromScreen( item, aScreen );
}
} }
if( itemList.GetCount() ) if( itemList.GetCount() )
@ -329,8 +340,9 @@ bool SCH_EDIT_FRAME::BreakSegmentsOnJunctions( SCH_SCREEN* aScreen )
void SCH_EDIT_FRAME::DeleteJunction( SCH_ITEM* aJunction, bool aAppend ) void SCH_EDIT_FRAME::DeleteJunction( SCH_ITEM* aJunction, bool aAppend )
{ {
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
PICKED_ITEMS_LIST itemList; PICKED_ITEMS_LIST itemList;
EE_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
auto remove_item = [ & ]( SCH_ITEM* aItem ) -> void auto remove_item = [ & ]( SCH_ITEM* aItem ) -> void
{ {
@ -372,7 +384,12 @@ void SCH_EDIT_FRAME::DeleteJunction( SCH_ITEM* aJunction, bool aAppend )
remove_item( item ); remove_item( item );
remove_item( secondItem ); remove_item( secondItem );
itemList.PushItem( ITEM_PICKER( line, UR_NEW ) ); itemList.PushItem( ITEM_PICKER( line, UR_NEW ) );
AddToScreen( line ); AddToScreen( line );
if( line->IsSelected() )
selectionTool->AddItemToSel( line, true /*quiet mode*/ );
break; break;
} }
} }
@ -386,7 +403,12 @@ void SCH_EDIT_FRAME::DeleteJunction( SCH_ITEM* aJunction, bool aAppend )
nextitem = item->Next(); nextitem = item->Next();
if( item->GetEditFlags() & STRUCT_DELETED ) if( item->GetEditFlags() & STRUCT_DELETED )
{
if( item->IsSelected() )
selectionTool->RemoveItemFromSel( item, true /*quiet mode*/ );
RemoveFromScreen( item ); RemoveFromScreen( item );
}
} }
} }

View File

@ -408,7 +408,7 @@ bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew )
// //
// If there are three or more endpoints // If there are three or more endpoints
if( pin_count + end_count[0] > 2 ) if( pin_count && pin_count + end_count[0] > 2 )
return true; return true;
// If there is at least one segment that ends on a non-parallel line or // If there is at least one segment that ends on a non-parallel line or