From 1a14809f167d3a30f42e47bf212487ffc505e0cb Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 27 Jan 2026 10:16:35 -0800 Subject: [PATCH] Fix via placement when pressing V before starting to route When the user presses V to place a via before clicking to start routing, the via placement intent was being ignored because ToggleViaPlacement() only works during active routing. The via would only appear if the user moved the mouse after pressing V. Add a flag to remember when V is pressed in pre-routing state and enable via placement after routing starts. Fixes https://gitlab.com/kicad/code/kicad/-/issues/19814 (cherry picked from commit f6a0b6b8369db85bd68241f3e720b9c02d522dbf) --- pcbnew/router/router_tool.cpp | 12 +++++++++++- pcbnew/router/router_tool.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 1010011386..bedbae12a8 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -209,7 +209,8 @@ ROUTER_TOOL::ROUTER_TOOL() : m_lastTargetLayer( UNDEFINED_LAYER ), m_originalActiveLayer( UNDEFINED_LAYER ), m_inRouterTool( false ), - m_inRouteSelected( false ) + m_inRouteSelected( false ), + m_startWithVia( false ) { } @@ -1311,6 +1312,13 @@ void ROUTER_TOOL::performRouting( VECTOR2D aStartPosition ) // Set initial cursor setCursor(); + // If the user pressed 'V' before starting to route, enable via placement now + if( m_startWithVia ) + { + m_startWithVia = false; + handleLayerSwitch( ACT_PlaceThroughVia.MakeEvent(), true ); + } + while( TOOL_EVENT* evt = Wait() ) { setCursor(); @@ -1767,6 +1775,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent ) m_router->SetMode( mode ); m_cancelled = false; + m_startWithVia = false; if( aEvent.HasPosition() ) m_toolMgr->PrimeTool( aEvent.Position() ); @@ -1834,6 +1843,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent ) } else if( evt->IsAction( &ACT_PlaceThroughVia ) ) { + m_startWithVia = true; m_toolMgr->RunAction( PCB_ACTIONS::layerToggle ); } else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) ) diff --git a/pcbnew/router/router_tool.h b/pcbnew/router/router_tool.h index ac63abd93d..5e763b8fe6 100644 --- a/pcbnew/router/router_tool.h +++ b/pcbnew/router/router_tool.h @@ -103,6 +103,8 @@ private: bool m_inRouterTool; // Re-entrancy guard bool m_inRouteSelected; + + bool m_startWithVia; // User pressed V before routing started }; #endif