Fix overzealous breakSegments()

We cannot break segements that are merely close or on endpoints, so we
filter these prior to the break routine.  Failing to do this was
overloading our undo stack with bogus values

Fixes https://gitlab.com/kicad/code/kicad/issues/7553

Fixes https://gitlab.com/kicad/code/kicad/issues/7557

Fixes https://gitlab.com/kicad/code/kicad/issues/7554
This commit is contained in:
Seth Hillbrand 2021-02-16 10:09:56 -08:00
parent df573255e0
commit 24795f5b12
3 changed files with 47 additions and 28 deletions

View File

@ -329,7 +329,15 @@ bool SCH_EDIT_FRAME::BreakSegments( const wxPoint& aPoint, SCH_SCREEN* aScreen )
for( auto item : aScreen->Items().Overlapping( SCH_LINE_T, aPoint ) )
{
if( item->IsType( wiresAndBuses ) )
wires.push_back( static_cast<SCH_LINE*>( item ) );
{
SCH_LINE* wire = static_cast<SCH_LINE*>( item );
if( IsPointOnSegment( wire->GetStartPoint(), wire->GetEndPoint(), aPoint )
&& !wire->IsEndPoint( aPoint ) )
{
wires.push_back( wire );
}
}
}
for( auto wire : wires )

View File

@ -175,8 +175,16 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
if( !aItemsList.GetCount() )
return;
if( aAppend )
commandToUndo = PopCommandFromUndoList();
PICKED_ITEMS_LIST* lastUndo = PopCommandFromUndoList();
// If the last stack was empty, use that one instead of creating a new stack
if( lastUndo )
{
if( aAppend || !lastUndo->GetCount() )
commandToUndo = lastUndo;
else
PushCommandToUndoList( lastUndo );
}
if( !commandToUndo )
commandToUndo = new PICKED_ITEMS_LIST();
@ -343,8 +351,12 @@ void SCH_EDIT_FRAME::RollbackSchematicFromUndo()
PICKED_ITEMS_LIST* undo = PopCommandFromUndoList();
// Skip empty frames
while( undo && undo->GetCount() == 1 && undo->GetPickedItemStatus( 0 ) == UNDO_REDO::NOP )
while( undo && ( !undo->GetCount()
|| ( undo->GetCount() == 1 && undo->GetPickedItemStatus( 0 ) == UNDO_REDO::NOP ) ) )
{
delete undo;
undo = PopCommandFromUndoList();
}
if( undo )
{

View File

@ -66,7 +66,6 @@
#include <dialogs/dialog_edit_label.h>
#include <core/kicad_algo.h>
#include <limits>
class SYMBOL_UNIT_MENU : public ACTION_MENU
{