diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index d71529d9c2..5f9dcbdb2d 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -108,6 +108,7 @@ #include #include +#include #include "../scripting/python_scripting.h" #include @@ -486,6 +487,8 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : PCB_EDIT_FRAME::~PCB_EDIT_FRAME() { + ScriptingOnDestructPcbEditFrame( this ); + if( ADVANCED_CFG::GetCfg().m_ShowEventCounters ) { // Stop the timer during destruction early to avoid potential event race conditions (that diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp index b1579db8be..652bf9e2ba 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp +++ b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo - * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2023 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 @@ -77,6 +77,13 @@ void ScriptingSetPcbEditFrame( PCB_EDIT_FRAME* aPcbEditFrame ) } +void ScriptingOnDestructPcbEditFrame( PCB_EDIT_FRAME* aPcbEditFrame ) +{ + if( s_PcbEditFrame == aPcbEditFrame ) + s_PcbEditFrame = nullptr; +} + + BOARD* LoadBoard( wxString& aFileName ) { if( aFileName.EndsWith( KiCadPcbFileExtension ) ) diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.h b/pcbnew/python/scripting/pcbnew_scripting_helpers.h index 08140283eb..68ea5a0aea 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.h +++ b/pcbnew/python/scripting/pcbnew_scripting_helpers.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo - * Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2013-2023 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 @@ -39,7 +39,8 @@ enum class EDA_UNITS; */ #ifndef SWIG -void ScriptingSetPcbEditFrame( PCB_EDIT_FRAME* aPCBEdaFrame ); +void ScriptingSetPcbEditFrame( PCB_EDIT_FRAME* aPCBEdaFrame ); +void ScriptingOnDestructPcbEditFrame( PCB_EDIT_FRAME* aPCBEdaFrame ); #endif