From 7e1498a46faf0bf28afd697cf2eeac6a868f0a2a Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 11 Dec 2018 15:15:47 +0100 Subject: [PATCH] Set the screen pointer to null before deleting the associated items VIEW needs to be cleared before deleting the stored items. Otherwise it may dereference stale pointers leading to a crash. --- eeschema/files-io.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 7cd6b0eaae..23bf1f25e8 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -235,6 +235,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in // unload current project file before loading new { + SetScreen( nullptr ); delete g_RootSheet; g_RootSheet = NULL; @@ -283,6 +284,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in } else { + SetScreen( nullptr ); delete g_RootSheet; // Delete the current project. g_RootSheet = NULL; // Force CreateScreens() to build new empty project on load failure. SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );