Check for valid shared pointer before locking

We don't neccesarily have a valid pointer to the parent lib symbol when
checking if it is a power symbol, so fall back to the local flag if this
is the case

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17182
This commit is contained in:
Seth Hillbrand 2024-04-11 14:41:28 -07:00
parent a155dd32e8
commit 4481fcc75e
1 changed files with 3 additions and 1 deletions

View File

@ -703,7 +703,9 @@ const wxString LIB_SYMBOL::GetLibraryName() const
bool LIB_SYMBOL::IsPower() const bool LIB_SYMBOL::IsPower() const
{ {
if( LIB_SYMBOL_SPTR parent = m_parent.lock() ) std::shared_ptr<LIB_SYMBOL> parent;
if( !m_parent.expired() && ( parent = m_parent.lock() ) )
{ {
if( parent->IsRoot() ) if( parent->IsRoot() )
return parent->m_options == ENTRY_POWER; return parent->m_options == ENTRY_POWER;