diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 1f3ef70bc2..dbc4f84c61 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -107,6 +107,7 @@ #include #include +#include #include "../scripting/python_scripting.h" #include @@ -477,6 +478,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 do happen on windows) diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp index 145d851f71..81a6bdcb55 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 1d522dd02f..dea0faa710 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 @@ -33,7 +33,8 @@ */ #ifndef SWIG -void ScriptingSetPcbEditFrame( PCB_EDIT_FRAME* aPCBEdaFrame ); +void ScriptingSetPcbEditFrame( PCB_EDIT_FRAME* aPCBEdaFrame ); +void ScriptingOnDestructPcbEditFrame( PCB_EDIT_FRAME* aPCBEdaFrame ); #endif