Free memory in dxf import sooner on bad_alloc

(cherry picked from commit b18e441a88)
This commit is contained in:
Marek Roszko 2022-04-02 09:57:30 -04:00 committed by Mark Roszko
parent 39959844e5
commit 455ec428f2
3 changed files with 19 additions and 0 deletions

View File

@ -124,6 +124,12 @@ bool DXF_IMPORT_PLUGIN::Load( const wxString& aFileName )
}
catch( const std::bad_alloc& )
{
m_layers.clear();
m_blocks.clear();
m_styles.clear();
m_internalImporter.ClearShapes();
reportMsg( _( "Memory was exhausted trying to load the DXF, it may be too large." ) );
return false;
}

View File

@ -189,6 +189,14 @@ public:
return m_items;
}
/**
* Empties out the imported shapes list
*/
void ClearItems()
{
m_items.clear();
}
///< Default line thickness (in mm)
static constexpr unsigned int DEFAULT_LINE_WIDTH_DFX = 1;

View File

@ -354,6 +354,11 @@ public:
return m_shapes;
}
void ClearShapes()
{
m_shapes.clear();
}
void PostprocessNestedPolygons();
protected: