From 5fea60d20f3312e21ba0546654b03e24da5a2463 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 30 Jan 2014 17:11:40 +0100 Subject: [PATCH] Fixed undo/redo while routing with the PNS error. --- pcbnew/router/router_tool.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index ed3eb18092..d7c29d10ff 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -290,6 +290,7 @@ void ROUTER_TOOL::updateEndItem( TOOL_EVENT& aEvent ) void ROUTER_TOOL::startRouting() { + bool saveUndoBuffer = true; VIEW_CONTROLS* ctls = getViewControls(); int width = getDefaultWidth( m_startItem ? m_startItem->GetNet() : -1 ); @@ -317,16 +318,16 @@ void ROUTER_TOOL::startRouting() { if( evt->IsCancel() ) break; + else if( evt->Action() == TA_UNDO_REDO ) + { + saveUndoBuffer = false; + break; + } else if( evt->IsMotion() ) { updateEndItem( *evt ); m_router->Move( m_endSnapPoint, m_endItem ); } - else if( evt->Action() == TA_UNDO_REDO ) - { - std::cout << "syncing the world while routing, I am going to craaaaaaaaaaaash!" << std::endl; - m_router->SyncWorld(); - } else if( evt->IsClick( BUT_LEFT ) ) { updateEndItem( *evt ); @@ -376,9 +377,17 @@ void ROUTER_TOOL::startRouting() m_router->StopRouting(); - // Save the recent changes in the undo buffer - getEditFrame()->SaveCopyInUndoList( m_router->GetLastChanges(), UR_UNSPECIFIED ); - getEditFrame()->OnModify(); + if( saveUndoBuffer ) + { + // Save the recent changes in the undo buffer + getEditFrame()->SaveCopyInUndoList( m_router->GetLastChanges(), UR_UNSPECIFIED ); + getEditFrame()->OnModify(); + } + else + { + // It was interrupted by TA_UNDO_REDO event, so we have to sync the world now + m_router->SyncWorld(); + } ctls->SetAutoPan( false ); ctls->ForceCursorPosition( false );