From 5476e97bfa47d3ae4b1d584a20f2a1096c4fd9aa Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Sat, 10 Dec 2016 10:20:21 -0500 Subject: [PATCH] Pcbnew: fix segfault when importing netlist with no footprint assignments. Fixes lp:1647803 https://bugs.launchpad.net/kicad/+bug/1647803 --- include/class_board_item.h | 10 ++-------- pcbnew/class_board_item.cpp | 13 ++++++++++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/class_board_item.h b/include/class_board_item.h index e492b11b89..131cf2240c 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2016 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 @@ -224,13 +224,7 @@ public: * Function DeleteStructure * deletes this object after UnLink()ing it from its owner if it has one. */ - void DeleteStructure() - { - if( GetList() != NULL ) - UnLink(); - - delete this; - } + void DeleteStructure(); /** * Function ShowShape diff --git a/pcbnew/class_board_item.cpp b/pcbnew/class_board_item.cpp index c1e60dbbf9..2f548bfb0e 100644 --- a/pcbnew/class_board_item.cpp +++ b/pcbnew/class_board_item.cpp @@ -8,7 +8,7 @@ * * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2016 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 @@ -247,3 +247,14 @@ int BOARD_ITEM::getNextNumberInSequence( const std::set& aSeq, bool aFillSe return candidate; } + + +void BOARD_ITEM::DeleteStructure() +{ + auto brd = GetBoard(); + + if( brd ) + brd->Remove( this ); + + delete this; +}