mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-04 23:05:30 +00:00
Removed shared_ptr circular references
When A references B and B references A, the shared pointer reference count will never go to zero by just removing the parent container. We need to explicitly clear the shared pointer references when we are done Fixes https://gitlab.com/kicad/code/kicad/-/issues/20272
This commit is contained in:
parent
4ef81ee3ea
commit
641e06e67c
@ -697,11 +697,29 @@ public:
|
||||
~CREEPAGE_GRAPH()
|
||||
{
|
||||
for( CREEP_SHAPE* cs : m_shapeCollection )
|
||||
{
|
||||
if( cs )
|
||||
{
|
||||
delete cs;
|
||||
cs = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// Clear out the circular shared pointer references
|
||||
for( std::shared_ptr<GRAPH_NODE>& n : m_nodes )
|
||||
{
|
||||
if( n )
|
||||
{
|
||||
n->m_node_conns.clear();
|
||||
n = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
for( std::shared_ptr<GRAPH_CONNECTION>& c : m_connections )
|
||||
{
|
||||
if( c )
|
||||
c = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user