From 1dc8585d04e185fd2ddf25924e15c4a07e44f65e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 21 Apr 2024 15:46:19 +0200 Subject: [PATCH] Footprint Editor: Fix crash when no footprint loaded and try to select something --- pcbnew/collectors.cpp | 3 ++- pcbnew/tools/pcb_selection_tool.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 824eceb055..43c9d29cdf 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2024 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 @@ -493,6 +493,7 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const std::vector& // the Inspect() function. SetRefPos( aRefPos ); + wxCHECK_RET( aItem, "" ); aItem->Visit( m_inspector, nullptr, m_scanTypes ); // append 2nd list onto end of the first list diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index 98dcf2e222..fce2518eac 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -414,8 +414,11 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( m_isFootprintEditor ) { - collector.Collect( board()->GetFirstFootprint(), { PCB_TABLECELL_T }, - evt->DragOrigin(), guide ); + if( board()->GetFirstFootprint() ) + { + collector.Collect( board()->GetFirstFootprint(), { PCB_TABLECELL_T }, + evt->DragOrigin(), guide ); + } } else {