From f00ec339fdcd4c740fd3c09a6a529ffc5dcb0426 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 24 Dec 2022 11:16:33 +0000 Subject: [PATCH] Don't set IS_NEW flags during clean-up operations. Fixes https://gitlab.com/kicad/code/kicad/issues/13252 --- eeschema/bus-wire-junction.cpp | 34 ++++++++++++++++++---------------- eeschema/sch_edit_frame.h | 3 +-- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 6201f28243..d8e1eae35a 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -118,20 +118,20 @@ bool SCH_EDIT_FRAME::TrimWire( const VECTOR2I& aStart, const VECTOR2I& aEnd ) continue; } - // Step 1: break the segment on one end. return_line remains line if not broken. + // Step 1: break the segment on one end. // Ensure that *line points to the segment containing aEnd - SCH_LINE* return_line = line; - BreakSegment( line, aStart, &return_line ); + SCH_LINE* new_line; + BreakSegment( line, aStart, &new_line ); - if( IsPointOnSegment( return_line->GetStartPoint(), return_line->GetEndPoint(), aEnd ) ) - line = return_line; + if( IsPointOnSegment( new_line->GetStartPoint(), new_line->GetEndPoint(), aEnd ) ) + line = new_line; - // Step 2: break the remaining segment. return_line remains line if not broken. + // Step 2: break the remaining segment. // Ensure that *line _also_ contains aStart. This is our overlapping segment - BreakSegment( line, aEnd, &return_line ); + BreakSegment( line, aEnd, &new_line ); - if( IsPointOnSegment( return_line->GetStartPoint(), return_line->GetEndPoint(), aStart ) ) - line = return_line; + if( IsPointOnSegment( new_line->GetStartPoint(), new_line->GetEndPoint(), aStart ) ) + line = new_line; SaveCopyInUndoList( screen, line, UNDO_REDO::DELETED, true ); RemoveFromScreen( line, screen ); @@ -294,7 +294,7 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( SCH_SCREEN* aScreen ) } -bool SCH_EDIT_FRAME::BreakSegment( SCH_LINE* aSegment, const VECTOR2I& aPoint, +void SCH_EDIT_FRAME::BreakSegment( SCH_LINE* aSegment, const VECTOR2I& aPoint, SCH_LINE** aNewSegment, SCH_SCREEN* aScreen ) { if( aScreen == nullptr ) @@ -310,15 +310,12 @@ bool SCH_EDIT_FRAME::BreakSegment( SCH_LINE* aSegment, const VECTOR2I& aPoint, SaveCopyInUndoList( aScreen, aSegment, UNDO_REDO::CHANGED, true ); aSegment->SetFlags( IS_CHANGED ); - newSegment->SetFlags( IS_NEW ); UpdateItem( aSegment, false, true ); aSegment->SetEndPoint( aPoint ); if( aNewSegment ) *aNewSegment = newSegment; - - return true; } @@ -345,7 +342,10 @@ bool SCH_EDIT_FRAME::BreakSegments( const VECTOR2I& aPoint, SCH_SCREEN* aScreen } for( SCH_LINE* wire : wires ) - brokenSegments |= BreakSegment( wire, aPoint, nullptr, aScreen ); + { + BreakSegment( wire, aPoint, nullptr, aScreen ); + brokenSegments = true; + } return brokenSegments; } @@ -370,9 +370,11 @@ bool SCH_EDIT_FRAME::BreakSegmentsOnJunctions( SCH_SCREEN* aScreen ) point_set.insert( entry->GetEnd() ); } - for( const VECTOR2I& pt : point_set ) - brokenSegments |= BreakSegments( pt, aScreen ); + { + BreakSegments( pt, aScreen ); + brokenSegments = true; + } return brokenSegments; } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index d79fd8b97b..7e1daee416 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -231,9 +231,8 @@ public: * @param aPoint Point at which to break the segment * @param aNewSegment Pointer to the newly created segment (if given and created) * @param aScreen is the screen to examine, or nullptr to examine the current screen. - * @return True if any wires or buses were broken. */ - bool BreakSegment( SCH_LINE* aSegment, const VECTOR2I& aPoint, + void BreakSegment( SCH_LINE* aSegment, const VECTOR2I& aPoint, SCH_LINE** aNewSegment = nullptr, SCH_SCREEN* aScreen = nullptr ); /**