Fix another case of selection getting out of sync with dragged items.

Use a big hammer this time.

Fixes: lp:1839780
* https://bugs.launchpad.net/kicad/+bug/1839780
This commit is contained in:
Jeff Young 2019-08-31 20:20:44 +01:00
parent e269b5d1b9
commit 5e353e8967
4 changed files with 28 additions and 24 deletions

View File

@ -459,12 +459,15 @@ EDA_ITEM* SCH_LINE::MergeOverlap( SCH_LINE* aLine )
} }
// Search for a common end: // Search for a common end:
if( ( leftmost_start == other_start ) && if( ( leftmost_start == other_start ) && ( leftmost_end == other_end ) ) // Trivial case
( leftmost_end == other_end ) ) // Trivial case
{ {
auto ret = new SCH_LINE( *aLine ); auto ret = new SCH_LINE( *aLine );
ret->SetStartPoint( leftmost_start ); ret->SetStartPoint( leftmost_start );
ret->SetEndPoint( leftmost_end ); ret->SetEndPoint( leftmost_end );
if( IsSelected() || aLine->IsSelected() )
ret->SetSelected();
return ret; return ret;
} }
@ -504,6 +507,10 @@ EDA_ITEM* SCH_LINE::MergeOverlap( SCH_LINE* aLine )
auto ret = new SCH_LINE( *aLine ); auto ret = new SCH_LINE( *aLine );
ret->SetStartPoint( leftmost_start ); ret->SetStartPoint( leftmost_start );
ret->SetEndPoint( leftmost_end ); ret->SetEndPoint( leftmost_end );
if( IsSelected() || aLine->IsSelected() )
ret->SetSelected();
return ret; return ret;
} }

View File

@ -181,6 +181,8 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Setup a drag or a move // Setup a drag or a move
// //
m_dragAdditions.clear();
for( SCH_ITEM* it = m_frame->GetScreen()->GetDrawItems(); it; it = it->Next() ) for( SCH_ITEM* it = m_frame->GetScreen()->GetDrawItems(); it; it = it->Next() )
{ {
it->ClearFlags(TEMP_SELECTED ); it->ClearFlags(TEMP_SELECTED );
@ -445,17 +447,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
if( unselect ) if( unselect )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
else else
{ m_selectionTool->RebuildSelection(); // Schematic cleanup might have merged lines, etc.
m_dragAdditions.clear();
for( SCH_ITEM* it = m_frame->GetScreen()->GetDrawItems(); it; it = it->Next() )
{
if( it->HasFlag( TEMP_SELECTED ) )
m_dragAdditions.push_back( it );
}
m_selectionTool->RemoveItemsFromSel( &m_dragAdditions, QUIET_MODE );
}
m_dragAdditions.clear(); m_dragAdditions.clear();
m_moveInProgress = false; m_moveInProgress = false;
@ -481,17 +473,17 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, wxPoint aPoi
if( testLine->GetStartPoint() == aPoint ) if( testLine->GetStartPoint() == aPoint )
{ {
if( !testLine->HasFlag(TEMP_SELECTED ) ) if( !testLine->HasFlag( TEMP_SELECTED ) )
aList.push_back( testLine ); aList.push_back( testLine );
testLine->SetFlags(STARTPOINT | TEMP_SELECTED ); testLine->SetFlags( STARTPOINT | TEMP_SELECTED );
} }
else if( testLine->GetEndPoint() == aPoint ) else if( testLine->GetEndPoint() == aPoint )
{ {
if( !testLine->HasFlag(TEMP_SELECTED ) ) if( !testLine->HasFlag( TEMP_SELECTED ) )
aList.push_back( testLine ); aList.push_back( testLine );
testLine->SetFlags(ENDPOINT | TEMP_SELECTED ); testLine->SetFlags( ENDPOINT | TEMP_SELECTED );
} }
break; break;
} }
@ -510,7 +502,7 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, wxPoint aPoi
newWire->SetFlags( IS_NEW ); newWire->SetFlags( IS_NEW );
m_frame->AddToScreen( newWire, m_frame->GetScreen() ); m_frame->AddToScreen( newWire, m_frame->GetScreen() );
newWire->SetFlags(TEMP_SELECTED | STARTPOINT ); newWire->SetFlags( TEMP_SELECTED | STARTPOINT );
aList.push_back( newWire ); aList.push_back( newWire );
} }
break; break;
@ -518,10 +510,10 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, wxPoint aPoi
case SCH_NO_CONNECT_T: case SCH_NO_CONNECT_T:
case SCH_JUNCTION_T: case SCH_JUNCTION_T:
// Select no-connects and junctions that are connected to items being moved. // Select no-connects and junctions that are connected to items being moved.
if( !test->HasFlag(TEMP_SELECTED ) && test->IsConnected( aPoint ) ) if( !test->HasFlag( TEMP_SELECTED ) && test->IsConnected( aPoint ) )
{ {
aList.push_back( test ); aList.push_back( test );
test->SetFlags(TEMP_SELECTED ); test->SetFlags( TEMP_SELECTED );
} }
break; break;
@ -531,8 +523,12 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, wxPoint aPoi
case SCH_HIER_LABEL_T: case SCH_HIER_LABEL_T:
case SCH_BUS_WIRE_ENTRY_T: case SCH_BUS_WIRE_ENTRY_T:
case SCH_BUS_BUS_ENTRY_T: case SCH_BUS_BUS_ENTRY_T:
// Performance optimization:
if( test->HasFlag( TEMP_SELECTED ) )
break;
// Select labels and bus entries that are connected to a wire being moved. // Select labels and bus entries that are connected to a wire being moved.
if( !test->HasFlag(TEMP_SELECTED ) && aOriginalItem->Type() == SCH_LINE_T ) if( aOriginalItem->Type() == SCH_LINE_T )
{ {
std::vector<wxPoint> connections; std::vector<wxPoint> connections;
test->GetConnectionPoints( connections ); test->GetConnectionPoints( connections );
@ -541,7 +537,7 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, wxPoint aPoi
{ {
if( aOriginalItem->HitTest( point ) ) if( aOriginalItem->HitTest( point ) )
{ {
test->SetFlags(TEMP_SELECTED ); test->SetFlags( TEMP_SELECTED );
aList.push_back( test ); aList.push_back( test );
break; break;
} }

View File

@ -269,7 +269,7 @@ public:
STATUS_FLAGS GetEditFlags() const STATUS_FLAGS GetEditFlags() const
{ {
int mask = EDA_ITEM_ALL_FLAGS - ( SELECTED | HIGHLIGHTED | BRIGHTENED | int mask = EDA_ITEM_ALL_FLAGS - ( SELECTED | TEMP_SELECTED | HIGHLIGHTED | BRIGHTENED |
STARTPOINT | ENDPOINT | IS_DANGLING | STARTPOINT | ENDPOINT | IS_DANGLING |
BEGIN_ONPAD | END_ONPAD | DP_COUPLED ); BEGIN_ONPAD | END_ONPAD | DP_COUPLED );
return m_Flags & mask; return m_Flags & mask;

View File

@ -258,7 +258,8 @@ void FP_CACHE::Load()
if( !dir.IsOpened() ) if( !dir.IsOpened() )
{ {
wxString msg = wxString::Format( _( "Footprint library path \"%s\" does not exist" ), wxString msg = wxString::Format( _( "Footprint library path '%s' does not exist "
"(or is not a directory)." ),
m_lib_raw_path ); m_lib_raw_path );
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
} }