3D-Viewer: properly clears the container

Fixes https://gitlab.com/kicad/code/kicad/issues/6346
This commit is contained in:
Mario Luzeiro 2020-11-11 09:42:14 +00:00
parent 2a3e6ee1b5
commit c08f9ac9f6
2 changed files with 14 additions and 4 deletions

View File

@ -55,7 +55,6 @@ void CGENERICCONTAINER2D::Clear()
++ii )
{
delete *ii;
*ii = NULL;
}
m_objects.clear();
@ -247,6 +246,12 @@ bool CBVHCONTAINER2D::IsPointInside( const SFVEC2F &aPoint ) const
}
*/
void CBVHCONTAINER2D::Clear()
{
CGENERICCONTAINER2D::Clear();
destroy();
}
void CBVHCONTAINER2D::destroy()
{
for( std::list<BVH_CONTAINER_NODE_2D *>::iterator ii = m_elements_to_delete.begin();
@ -254,10 +259,9 @@ void CBVHCONTAINER2D::destroy()
++ii )
{
delete *ii;
*ii = NULL;
}
m_elements_to_delete.clear();
m_Tree = nullptr;
m_isInitialized = false;
}
@ -385,6 +389,8 @@ void CBVHCONTAINER2D::recursiveBuild_MIDDLE_SPLIT( BVH_CONTAINER_NODE_2D *aNodeP
recursiveBuild_MIDDLE_SPLIT( leftNode );
recursiveBuild_MIDDLE_SPLIT( rightNode );
wxASSERT( aNodeParent->m_LeafList.size() == 0 );
}
else
{
@ -392,6 +398,9 @@ void CBVHCONTAINER2D::recursiveBuild_MIDDLE_SPLIT( BVH_CONTAINER_NODE_2D *aNodeP
aNodeParent->m_Children[0] = NULL;
aNodeParent->m_Children[1] = NULL;
}
wxASSERT( aNodeParent != NULL );
wxASSERT( aNodeParent->m_BBox.IsInitialized() == true );
}

View File

@ -64,7 +64,7 @@ public:
return m_bbox;
}
void Clear();
virtual void Clear();
const LIST_OBJECT2D &GetList() const { return m_objects; }
@ -119,6 +119,7 @@ public:
void BuildBVH();
void Clear();
private:
bool m_isInitialized;
std::list<BVH_CONTAINER_NODE_2D *> m_elements_to_delete;