From d0e86cad7cc4cd4ba00ca1ea96656d0007f65006 Mon Sep 17 00:00:00 2001
From: Jeff Young <jeff@rokeby.ie>
Date: Mon, 3 Mar 2025 10:55:59 +0000
Subject: [PATCH] Disable multi-via dragging.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20150
---
 pcbnew/tools/pcb_selection_tool.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp
index b625813622..d948cb8011 100644
--- a/pcbnew/tools/pcb_selection_tool.cpp
+++ b/pcbnew/tools/pcb_selection_tool.cpp
@@ -515,12 +515,16 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
 
                 if( doDrag )
                 {
-                    bool isTracks = m_selection.GetSize() > 0
-                            && m_selection.OnlyContains( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } );
+                    size_t segs = m_selection.CountType( PCB_TRACE_T );
+                    size_t arcs = m_selection.CountType( PCB_ARC_T );
+                    size_t vias = m_selection.CountType( PCB_VIA_T );
+                    // Note: multi-track dragging is currently supported, but not multi-via
+                    bool   routable = ( segs >= 1 || arcs >= 1 || vias == 1 )
+                                        && ( segs + arcs + vias == m_selection.GetSize() );
 
-                    if( isTracks && trackDragAction == TRACK_DRAG_ACTION::DRAG )
+                    if( routable && trackDragAction == TRACK_DRAG_ACTION::DRAG )
                         m_toolMgr->RunAction( PCB_ACTIONS::drag45Degree );
-                    else if( isTracks && trackDragAction == TRACK_DRAG_ACTION::DRAG_FREE_ANGLE )
+                    else if( routable && trackDragAction == TRACK_DRAG_ACTION::DRAG_FREE_ANGLE )
                         m_toolMgr->RunAction( PCB_ACTIONS::dragFreeAngle );
                     else
                         m_toolMgr->RunAction( PCB_ACTIONS::move );