Free memory in dxf import sooner on bad_alloc

This commit is contained in:
Marek Roszko 2022-04-02 09:57:30 -04:00
parent 9f8c0a8185
commit b18e441a88
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

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