From 63d3c835cbbce5e3463207a14b236f997d83f391 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 18 Feb 2015 10:13:17 +0100 Subject: [PATCH] Pcbnew: refinement to Bug #1422093 fix. --- pcbnew/class_module.cpp | 27 +++++++++++++++++++++------ pcbnew/class_module.h | 15 ++++++++++++--- pcbnew/loadcmp.cpp | 15 +++++++-------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index c6e0b5d5e5..dfeddedb2f 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -1,10 +1,10 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr - * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2012 Wayne Stambaugh - * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr + * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2015 Wayne Stambaugh + * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -68,8 +68,8 @@ MODULE::MODULE( BOARD* parent ) : m_LocalSolderPasteMargin = 0; m_LocalSolderPasteMarginRatio = 0.0; m_ZoneConnection = UNDEFINED_CONNECTION; // Use zone setting by default - m_ThermalWidth = 0; // Use zone setting by default - m_ThermalGap = 0; // Use zone setting by default + m_ThermalWidth = 0; // Use zone setting by default + m_ThermalGap = 0; // Use zone setting by default // These are special and mandatory text fields m_Reference = new TEXTE_MODULE( this, TEXTE_MODULE::TEXT_is_REFERENCE ); @@ -174,6 +174,21 @@ MODULE::~MODULE() delete m_initial_comments; } + /** + * Function ClearAllNets + * Clear (i.e. force the ORPHANED dummy net info) the net info which + * depends on a given board for all pads of the footprint. + * This is needed when a footprint is copied between the fp editor and + * the board editor for instance, because net info become fully broken + */ +void MODULE::ClearAllNets() +{ + // Force the ORPHANED dummy net info for all pads. + // ORPHANED dummy net does not depend on a board + for( D_PAD* pad = Pads(); pad; pad = pad->Next() ) + pad->SetNetCode( NETINFO_LIST::FORCE_ORPHANED ); +} + /* Draw the anchor cross (vertical) * Must be done after the pads, because drawing the hole will erase overwrite diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 266b033e3f..2ba023cec2 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -93,7 +93,7 @@ public: void Copy( MODULE* Module ); // Copy structure - /* + /** * Function Add * adds the given item to this MODULE and takes ownership of its memory. * @param aBoardItem The item to add to this board. @@ -123,6 +123,15 @@ public: */ BOARD_ITEM* Remove( BOARD_ITEM* aBoardItem ); + /** + * Function ClearAllNets + * Clear (i.e. force the ORPHANED dummy net info) the net info which + * depends on a given board for all pads of the footprint. + * This is needed when a footprint is copied between the fp editor and + * the board editor for instance, because net info become fully broken + */ + void ClearAllNets(); + /** * Function CalculateBoundingBox * calculates the bounding box in board coordinates. diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 63034f561c..94fdbc8846 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -101,8 +101,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule ) // Morever we do not want to save any reference to an unknown net when // saving the footprint in lib cache // so we force the ORPHANED dummy net info for all pads - for( D_PAD* pad = newModule->Pads(); pad; pad = pad->Next() ) - pad->SetNetCode( NETINFO_LIST::FORCE_ORPHANED ); + newModule->ClearAllNets(); SetCrossHairPosition( wxPoint( 0, 0 ) ); PlaceModule( newModule, NULL ); @@ -332,12 +331,12 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId ) MODULE* module = fptbl->FootprintLoadWithOptionalNickname( aFootprintId ); - // Clear all references to any net info, to be sure there is no broken links - // to any netinfo list (should be not needed, but...) -#if 0 // FIXME : currently crashes Pcbnew. should not. - for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() ) - pad->SetNetCode( NETINFO_LIST::FORCE_ORPHANED ); -#endif + // If the module is found, clear all net info, + // to be sure there is no broken links + // to any netinfo list (should be not needed, but it can be edited from + // the footprint editor ) + if( module ) + module->ClearAllNets(); return module; }