From 1d223d143915233456e9961c78c6c615c88948d5 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 17 Jan 2023 12:55:39 -0800 Subject: [PATCH] Safely load python plugins Catch potential exceptions when doing the initial python plugin load Fixes https://gitlab.com/kicad/code/kicad/issues/12231 --- pcbnew/python/scripting/pcb_scripting_tool.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pcbnew/python/scripting/pcb_scripting_tool.cpp b/pcbnew/python/scripting/pcb_scripting_tool.cpp index fd4fe11745..507df0a620 100644 --- a/pcbnew/python/scripting/pcb_scripting_tool.cpp +++ b/pcbnew/python/scripting/pcb_scripting_tool.cpp @@ -80,8 +80,13 @@ void SCRIPTING_TOOL::ReloadPlugins() // Remove all action plugins so that we don't keep references to old versions ACTION_PLUGINS::UnloadAll(); - PyLOCK lock; - callLoadPlugins(); + try + { + PyLOCK lock; + callLoadPlugins(); + } + catch( ... ) + {} } @@ -91,10 +96,15 @@ int SCRIPTING_TOOL::reloadPlugins( const TOOL_EVENT& aEvent ) // Remove all action plugins so that we don't keep references to old versions ACTION_PLUGINS::UnloadAll(); + try { PyLOCK lock; callLoadPlugins(); } + catch( ... ) + { + return -1; + } if( !m_isFootprintEditor ) {