From f5246acf3741b233efd676e728ac9b7804daf209 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 28 Nov 2021 13:18:53 +0100 Subject: [PATCH] PCB_PAINTER: draw PAD do not always replace netname by "x". When a pad net is edited inside the board editor, its netname is no longer its corresponding pin netname. Fixes #9795 https://gitlab.com/kicad/code/kicad/issues/9795 --- pcbnew/pcb_painter.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 8e852edcba..1766ab2e14 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -977,10 +977,17 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) wxString netname = UnescapeString( aPad->GetShortNetname() ); wxString pinType = aPad->GetPinType(); - if( pinType == wxT( "no_connect" ) || pinType.EndsWith( wxT( "+no_connect" ) ) ) - netname = "x"; - else if( pinType == wxT( "free" ) && netname.StartsWith( wxT( "unconnected-(" ) ) ) - netname = "*"; + // If the pad is actually not connected (unique pad in the net), + // shorten the displayed netname (actual name not useful) + // Can happen if the pad netname is edited inside the board editor, therefore + // having a netname not coming from schematic + if( netname.StartsWith( "unconnected-(" ) ) + { + if( pinType == wxT( "no_connect" ) || pinType.EndsWith( wxT( "+no_connect" ) ) ) + netname = "x"; + else if( pinType == wxT( "free" ) ) + netname = "*"; + } // approximate the size of net name text: double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( netname ), 1 );