diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 3232d5ad5d..9b7f920e3e 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -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( item ) ); + { + SCH_LINE* wire = static_cast( item ); + + if( IsPointOnSegment( wire->GetStartPoint(), wire->GetEndPoint(), aPoint ) + && !wire->IsEndPoint( aPoint ) ) + { + wires.push_back( wire ); + } + } } for( auto wire : wires ) diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index 8dc47cfd18..d8e94525e4 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -97,8 +97,8 @@ void SCH_EDIT_FRAME::StartNewUndo() { - PICKED_ITEMS_LIST* blank = new PICKED_ITEMS_LIST(); - PushCommandToUndoList( blank ); + PICKED_ITEMS_LIST* blank = new PICKED_ITEMS_LIST(); + PushCommandToUndoList( blank ); } @@ -114,16 +114,16 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_SCREEN* aScreen, // Connectivity may change aItem->SetConnectivityDirty(); - PICKED_ITEMS_LIST* lastUndo = 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 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 ) { @@ -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(); @@ -267,7 +275,7 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) if( status == UNDO_REDO::NOP ) { - continue; + continue; } if( status == UNDO_REDO::NEWITEM ) { @@ -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 ) - undo = PopCommandFromUndoList(); + while( undo && ( !undo->GetCount() + || ( undo->GetCount() == 1 && undo->GetPickedItemStatus( 0 ) == UNDO_REDO::NOP ) ) ) + { + delete undo; + undo = PopCommandFromUndoList(); + } if( undo ) { diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 83268dccc7..6e79c564e0 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -66,7 +66,6 @@ #include #include -#include class SYMBOL_UNIT_MENU : public ACTION_MENU { @@ -1692,21 +1691,21 @@ int SCH_EDIT_TOOL::BreakWire( const TOOL_EVENT& aEvent ) for( auto& item : selection ) { - if( SCH_LINE* line = dyn_cast( item ) ) - { - if( !line->IsEndPoint( cursorPos ) ) - lines.push_back( line ); - } + if( SCH_LINE* line = dyn_cast( item ) ) + { + if( !line->IsEndPoint( cursorPos ) ) + lines.push_back( line ); + } } m_selectionTool->ClearSelection(); - m_frame->StartNewUndo(); + m_frame->StartNewUndo(); - for( SCH_LINE* line : lines ) - m_frame->BreakSegment( line, cursorPos ); + for( SCH_LINE* line : lines ) + m_frame->BreakSegment( line, cursorPos ); - if( !lines.empty() ) - { + if( !lines.empty() ) + { if( m_frame->GetScreen()->IsJunctionNeeded( cursorPos, true ) ) m_frame->AddJunction( m_frame->GetScreen(), cursorPos, true, false );