diff --git a/pcbnew/router/pns_dragger.cpp b/pcbnew/router/pns_dragger.cpp index 27b45d36d9..550dac2fe4 100644 --- a/pcbnew/router/pns_dragger.cpp +++ b/pcbnew/router/pns_dragger.cpp @@ -83,6 +83,9 @@ bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA* aVia ) VECTOR2I p0( aVia->Pos() ); PNS_JOINT* jt = m_world->FindJoint( p0, aVia->Layers().Start(), aVia->Net() ); + if( !jt ) + return false; + BOOST_FOREACH( PNS_ITEM* item, jt->LinkList() ) { if( item->OfKind( PNS_ITEM::SEGMENT ) ) diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index 1f01b16330..46f19896db 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -195,48 +195,48 @@ void PNS_TOOL_BASE::updateStartItem( TOOL_EVENT& aEvent ) { int tl = getView()->GetTopLayer(); VECTOR2I cp = m_ctls->GetCursorPosition(); + VECTOR2I p; + PNS_ITEM* startItem = NULL; + bool snapEnabled = true; if( aEvent.IsMotion() || aEvent.IsClick() ) { - bool snapEnabled = !aEvent.Modifier( MD_SHIFT ); + snapEnabled = !aEvent.Modifier( MD_SHIFT ); + p = aEvent.Position(); + } else { + p = cp; + } - VECTOR2I p( aEvent.Position() ); - startItem = pickSingleItem( p ); - m_router->EnableSnapping ( snapEnabled ); + startItem = pickSingleItem( p ); + m_router->EnableSnapping ( snapEnabled ); - if( !snapEnabled && startItem && !startItem->Layers().Overlaps( tl ) ) - startItem = NULL; + if( !snapEnabled && startItem && !startItem->Layers().Overlaps( tl ) ) + startItem = NULL; - if( startItem && startItem->Net() >= 0 ) + if( startItem && startItem->Net() >= 0 ) + { + bool dummy; + VECTOR2I psnap = m_router->SnapToItem( startItem, p, dummy ); + + if( snapEnabled ) { - bool dummy; - VECTOR2I psnap = m_router->SnapToItem( startItem, p, dummy ); - - if( snapEnabled ) - { - m_startSnapPoint = psnap; - m_ctls->ForceCursorPosition( true, psnap ); - } - else - { - m_startSnapPoint = cp; - m_ctls->ForceCursorPosition( false ); - } - -// if( startItem->Layers().IsMultilayer() ) -// m_startLayer = tl; -// else -// m_startLayer = startItem->Layers().Start(); - - m_startItem = startItem; + m_startSnapPoint = psnap; + m_ctls->ForceCursorPosition( true, psnap ); } else { - m_startItem = NULL; m_startSnapPoint = cp; m_ctls->ForceCursorPosition( false ); } + + m_startItem = startItem; + } + else + { + m_startItem = NULL; + m_startSnapPoint = cp; + m_ctls->ForceCursorPosition( false ); } } diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index ac491e3ddf..2162fa5eaf 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -660,7 +660,10 @@ int ROUTER_TOOL::mainLoop( PNS_ROUTER_MODE aMode ) performRouting(); } else if( evt->IsAction( &ACT_Drag ) ) + { + updateStartItem( *evt ); performDragging(); + } handleCommonEvents( *evt ); } @@ -731,6 +734,8 @@ void ROUTER_TOOL::performDragging() m_needsSync = true; } + m_startItem = NULL; + ctls->SetAutoPan( false ); ctls->ForceCursorPosition( false ); highlightNet( false );