Fix library symbol rescue issues.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/13602
(cherry picked from commit 0a7bd85cd6
)
This commit is contained in:
parent
5a36c3685e
commit
b33cf23bda
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Chris Pavlina <pavlina.chris@gmail.com>
|
* Copyright (C) 2015 Chris Pavlina <pavlina.chris@gmail.com>
|
||||||
* Copyright (C) 2015-2022 KiCad Developers, see change_log.txt for contributors.
|
* Copyright (C) 2015-2023 KiCad Developers, see change_log.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -144,7 +144,6 @@ void RESCUE_CASE_CANDIDATE::FindRescues( RESCUER& aRescuer,
|
||||||
std::vector<LIB_SYMBOL*> case_insensitive_matches;
|
std::vector<LIB_SYMBOL*> case_insensitive_matches;
|
||||||
|
|
||||||
wxString symbol_name;
|
wxString symbol_name;
|
||||||
wxString search_name;
|
|
||||||
wxString last_symbol_name;
|
wxString last_symbol_name;
|
||||||
|
|
||||||
for( SCH_SYMBOL* eachSymbol : *( aRescuer.GetSymbols() ) )
|
for( SCH_SYMBOL* eachSymbol : *( aRescuer.GetSymbols() ) )
|
||||||
|
@ -164,9 +163,22 @@ void RESCUE_CASE_CANDIDATE::FindRescues( RESCUER& aRescuer,
|
||||||
case_sensitive_match = aRescuer.GetPrj()->SchLibs()->FindLibSymbol( id );
|
case_sensitive_match = aRescuer.GetPrj()->SchLibs()->FindLibSymbol( id );
|
||||||
|
|
||||||
// If the case sensitive match failed, try a case insensitive match.
|
// If the case sensitive match failed, try a case insensitive match.
|
||||||
if( !case_sensitive_match )
|
if( case_sensitive_match )
|
||||||
|
continue;
|
||||||
|
|
||||||
aRescuer.GetPrj()->SchLibs()->FindLibraryNearEntries( case_insensitive_matches,
|
aRescuer.GetPrj()->SchLibs()->FindLibraryNearEntries( case_insensitive_matches,
|
||||||
search_name );
|
symbol_name );
|
||||||
|
|
||||||
|
// If there are not case insensitive matches either, the symbol cannot be rescued.
|
||||||
|
if( !case_insensitive_matches.size() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
RESCUE_CASE_CANDIDATE candidate( symbol_name, case_insensitive_matches[0]->GetName(),
|
||||||
|
case_insensitive_matches[0],
|
||||||
|
eachSymbol->GetUnit(),
|
||||||
|
eachSymbol->GetConvert() );
|
||||||
|
|
||||||
|
candidate_map[symbol_name] = candidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( case_sensitive_match || !( case_insensitive_matches.size() ) )
|
if( case_sensitive_match || !( case_insensitive_matches.size() ) )
|
||||||
|
@ -198,6 +210,12 @@ wxString RESCUE_CASE_CANDIDATE::GetActionDescription() const
|
||||||
|
|
||||||
bool RESCUE_CASE_CANDIDATE::PerformAction( RESCUER* aRescuer )
|
bool RESCUE_CASE_CANDIDATE::PerformAction( RESCUER* aRescuer )
|
||||||
{
|
{
|
||||||
|
wxCHECK( m_lib_candidate, true );
|
||||||
|
|
||||||
|
std::unique_ptr<LIB_SYMBOL> new_symbol = m_lib_candidate->Flatten();
|
||||||
|
new_symbol->SetName( m_new_name );
|
||||||
|
aRescuer->AddSymbol( new_symbol.get() );
|
||||||
|
|
||||||
for( SCH_SYMBOL* eachSymbol : *aRescuer->GetSymbols() )
|
for( SCH_SYMBOL* eachSymbol : *aRescuer->GetSymbols() )
|
||||||
{
|
{
|
||||||
if( eachSymbol->GetLibId().GetLibItemName() != UTF8( m_requested_name ) )
|
if( eachSymbol->GetLibId().GetLibItemName() != UTF8( m_requested_name ) )
|
||||||
|
@ -316,7 +334,9 @@ bool RESCUE_CACHE_CANDIDATE::PerformAction( RESCUER* aRescuer )
|
||||||
{
|
{
|
||||||
LIB_SYMBOL* tmp = ( m_cache_candidate ) ? m_cache_candidate : m_lib_candidate;
|
LIB_SYMBOL* tmp = ( m_cache_candidate ) ? m_cache_candidate : m_lib_candidate;
|
||||||
|
|
||||||
wxCHECK_MSG( tmp, false, wxT( "Both cache and library symbols undefined." ) );
|
// A symbol that cannot be rescued is a valid condition so just bail out here.
|
||||||
|
if( !tmp )
|
||||||
|
return true;
|
||||||
|
|
||||||
std::unique_ptr<LIB_SYMBOL> new_symbol = tmp->Flatten();
|
std::unique_ptr<LIB_SYMBOL> new_symbol = tmp->Flatten();
|
||||||
new_symbol->SetName( m_new_name );
|
new_symbol->SetName( m_new_name );
|
||||||
|
|
Loading…
Reference in New Issue