From 540fb91d34304d648a4c25e7c1393406df7702f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mr=C3=A1zek?= Date: Mon, 28 Dec 2020 23:22:16 +0100 Subject: [PATCH] Backport 93466fa1: Fix crash when adding 3D Models via Python --- pcbnew/class_module.cpp | 2 -- pcbnew/pcb_parser.cpp | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index b3fc288bef..4c34aef098 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -783,8 +783,6 @@ void MODULE::Add3DModel( MODULE_3D_SETTINGS* a3DModel ) if( !a3DModel->m_Filename.empty() ) m_3D_Drawings.push_back( *a3DModel ); - - delete a3DModel; } diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index f2c13cb423..99569b3e77 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -2182,7 +2182,11 @@ MODULE* PCB_PARSER::parseMODULE_unchecked( wxArrayString* aInitialComments ) break; case T_model: - module->Add3DModel( parse3DModel() ); + { + MODULE_3D_SETTINGS* model = parse3DModel(); + module->Add3DModel( model ); + delete model; + } break; default: