diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index e3152ee65e..837cece526 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -266,10 +266,14 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList() if( m_mode == MODE::UPDATE && symbol->GetPartRef() ) { - symbol->GetPartRef()->Flatten()->GetFields( libFields ); + std::unique_ptr flattenedPart = symbol->GetPartRef()->Flatten(); + + flattenedPart->GetFields( libFields ); for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i ) fieldNames.insert( libFields[i]->GetName() ); + + libFields.clear(); // flattenedPart is about to go out of scope... } } }