diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 8d6eace662..02826443c4 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -73,7 +73,9 @@ static void abortMoveText( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) wxCHECK_RET( item != NULL, wxT( "Cannot restore undefined last text item." ) ); screen->AddToDrawList( item ); + // the owner of item is no more parent, this is the draw list of screen: parent->SetUndoItem( NULL ); + item->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); item->ClearFlags(); } diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 95a261a9e5..03b91e248b 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -337,7 +337,9 @@ void SCH_TEXT::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) undoItem->ClearFlags(); picker.SetLink( undoItem ); + // the owner of undoItem is no more frame, this is picker: frame->SetUndoItem( NULL ); + pickList.PushItem( picker ); frame->SaveCopyInUndoList( pickList, UR_EXCHANGE_T ); } diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index ee8e5af145..1b50d32045 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -352,15 +352,20 @@ void SCH_EDIT_FRAME::CreateScreens() void SCH_EDIT_FRAME::SetUndoItem( const SCH_ITEM* aItem ) { - if( m_undoItem != NULL ) + // if aItem != NULL, delete a previous m_undoItem, if exists + // if aItme = NULL, just clear m_undoItem, + // because when calling SetUndoItem( NULL ), we only clear m_undoItem, + // because the owner of m_undoItem is no more me. + if( aItem && m_undoItem ) { delete m_undoItem; - m_undoItem = NULL; } + m_undoItem = NULL; if( aItem ) m_undoItem = aItem->Clone(); + } diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 8047362b90..c779dbaf3d 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -261,7 +261,9 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) wxCHECK_RET( item != NULL, wxT( "Cannot restore undefined last sheet item." ) ); screen->AddToDrawList( item ); + // the owner of item is no more parent, this is the draw list of screen: parent->SetUndoItem( NULL ); + item->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); item->ClearFlags(); SCH_SHEET* sheet = ( SCH_SHEET* ) item; diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 1e10128f05..80eba3b451 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -310,9 +310,9 @@ bool PCB_EDIT_FRAME::Add_45_degrees_Segment( wxDC* DC ) return false; } - int pas_45 = wxRound( GetScreen()->GetGridSize().x / 2 ); - if( pas_45 < curTrack->m_Width ) - pas_45 = curTrack->m_Width; + int segm_step_45 = wxRound( GetScreen()->GetGridSize().x / 2 ); + if( segm_step_45 < ( curTrack->m_Width * 2 ) ) + segm_step_45 = curTrack->m_Width * 2; // Test if the segments are horizontal or vertical. dx0 = prevTrack->m_End.x - prevTrack->m_Start.x; @@ -322,10 +322,10 @@ bool PCB_EDIT_FRAME::Add_45_degrees_Segment( wxDC* DC ) dy1 = curTrack->m_End.y - curTrack->m_Start.y; // Segments must be of sufficient length. - if( MAX( abs( dx0 ), abs( dy0 ) ) < ( pas_45 * 2 ) ) + if( MAX( abs( dx0 ), abs( dy0 ) ) < ( segm_step_45 * 2 ) ) return false; - if( MAX( abs( dx1 ), abs( dy1 ) ) < ( pas_45 * 2 ) ) + if( MAX( abs( dx1 ), abs( dy1 ) ) < ( segm_step_45 * 2 ) ) return false; /* Create a new segment and connect it with the previous 2 segments. */ @@ -347,14 +347,14 @@ bool PCB_EDIT_FRAME::Add_45_degrees_Segment( wxDC* DC ) * horizontal segment. */ if( dy0 > 0 ) - newTrack->m_Start.y -= pas_45; + newTrack->m_Start.y -= segm_step_45; else - newTrack->m_Start.y += pas_45; + newTrack->m_Start.y += segm_step_45; if( dx1 > 0 ) - newTrack->m_End.x += pas_45; + newTrack->m_End.x += segm_step_45; else - newTrack->m_End.x -= pas_45; + newTrack->m_End.x -= segm_step_45; if( Drc_On && BAD_DRC == m_drc->Drc( curTrack, GetBoard()->m_Track ) ) { @@ -382,14 +382,14 @@ bool PCB_EDIT_FRAME::Add_45_degrees_Segment( wxDC* DC ) * (horizontal) and segment 2 (vertical) */ if( dx0 > 0 ) - newTrack->m_Start.x -= pas_45; + newTrack->m_Start.x -= segm_step_45; else - newTrack->m_Start.x += pas_45; + newTrack->m_Start.x += segm_step_45; if( dy1 > 0 ) - newTrack->m_End.y += pas_45; + newTrack->m_End.y += segm_step_45; else - newTrack->m_End.y -= pas_45; + newTrack->m_End.y -= segm_step_45; if( Drc_On && BAD_DRC==m_drc->Drc( newTrack, GetBoard()->m_Track ) ) {