Fix memory leak.

Also removed some unnecessary aliases.
This commit is contained in:
tamasmeszaros 2019-08-29 10:10:09 +02:00
parent af2a3d2c08
commit d3fdb0a0e6
2 changed files with 7 additions and 9 deletions

View file

@ -454,7 +454,7 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, DynamicPrintConfig con
} }
if(m_objects.empty()) { if(m_objects.empty()) {
m_printer.release(); m_printer.reset();
m_printer_input.clear(); m_printer_input.clear();
m_print_statistics.clear(); m_print_statistics.clear();
} }
@ -1397,13 +1397,14 @@ void SLAPrint::process()
{ // create a raster printer for the current print parameters { // create a raster printer for the current print parameters
double layerh = m_default_object_config.layer_height.getFloat(); double layerh = m_default_object_config.layer_height.getFloat();
m_printer.reset(new SLAPrinter(m_printer_config, m_printer.reset(new sla::SLARasterWriter(m_printer_config,
m_material_config, m_material_config,
layerh)); layerh));
} }
// Allocate space for all the layers // Allocate space for all the layers
SLAPrinter& printer = *m_printer; sla::SLARasterWriter &printer = *m_printer;
auto lvlcnt = unsigned(m_printer_input.size()); auto lvlcnt = unsigned(m_printer_input.size());
printer.layers(lvlcnt); printer.layers(lvlcnt);

View file

@ -422,9 +422,6 @@ public:
const std::vector<PrintLayer>& print_layers() const { return m_printer_input; } const std::vector<PrintLayer>& print_layers() const { return m_printer_input; }
private: private:
using SLAPrinter = sla::SLARasterWriter;
using SLAPrinterPtr = std::unique_ptr<SLAPrinter>;
// Implement same logic as in SLAPrintObject // Implement same logic as in SLAPrintObject
bool invalidate_step(SLAPrintStep st); bool invalidate_step(SLAPrintStep st);
@ -443,7 +440,7 @@ private:
std::vector<PrintLayer> m_printer_input; std::vector<PrintLayer> m_printer_input;
// The printer itself // The printer itself
SLAPrinterPtr m_printer; std::unique_ptr<sla::SLARasterWriter> m_printer;
// Estimated print time, material consumed. // Estimated print time, material consumed.
SLAPrintStatistics m_print_statistics; SLAPrintStatistics m_print_statistics;