#8252 - GCodeViewer - Fixed crash when importing invalid gcode
This commit is contained in:
parent
411535ecdf
commit
8abb8a6546
@ -223,7 +223,10 @@ bool Bed3D::set_shape(const Pointfs& bed_shape, const double max_print_height, c
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_contour = ExPolygon(Polygon::new_scale(bed_shape));
|
||||
m_polygon = offset(m_contour.contour, (float)m_contour.contour.bounding_box().radius() * 1.7f, jtRound, scale_(0.5)).front();
|
||||
const BoundingBox bbox = m_contour.contour.bounding_box();
|
||||
if (!bbox.defined)
|
||||
throw RuntimeError(std::string("Invalid bed shape"));
|
||||
m_polygon = offset(m_contour.contour, (float)bbox.radius() * 1.7f, jtRound, scale_(0.5)).front();
|
||||
|
||||
m_triangles.reset();
|
||||
m_gridlines.reset();
|
||||
|
@ -538,7 +538,7 @@ void MainFrame::update_layout()
|
||||
case ESettingsLayout::GCodeViewer:
|
||||
{
|
||||
m_main_sizer->Add(m_plater, 1, wxEXPAND);
|
||||
m_plater->set_bed_shape({ { 0.0, 0.0 }, { 200.0, 0.0 }, { 200.0, 200.0 }, { 0.0, 200.0 } }, 0.0, {}, {}, true);
|
||||
m_plater->set_default_bed_shape();
|
||||
m_plater->get_collapse_toolbar().set_enabled(false);
|
||||
m_plater->collapse_sidebar(true);
|
||||
m_plater->Show();
|
||||
|
@ -5477,10 +5477,27 @@ void Plater::load_gcode(const wxString& filename)
|
||||
p->gcode_result = std::move(processor.extract_result());
|
||||
|
||||
// show results
|
||||
p->preview->reload_print(false);
|
||||
try
|
||||
{
|
||||
p->preview->reload_print(false);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
wxEndBusyCursor();
|
||||
p->gcode_result.reset();
|
||||
reset_gcode_toolpaths();
|
||||
set_default_bed_shape();
|
||||
p->preview->reload_print(false);
|
||||
p->get_current_canvas3D()->render();
|
||||
MessageDialog(this, _L("The selected file") + ":\n" + filename + "\n" + _L("does not contain valid gcode."),
|
||||
wxString(GCODEVIEWER_APP_NAME) + " - " + _L("Error while loading .gcode file"), wxOK | wxICON_WARNING | wxCENTRE).ShowModal();
|
||||
set_project_filename(wxEmptyString);
|
||||
return;
|
||||
}
|
||||
p->preview->get_canvas3d()->zoom_to_gcode();
|
||||
|
||||
if (p->preview->get_canvas3d()->get_gcode_layers_zs().empty()) {
|
||||
wxEndBusyCursor();
|
||||
//wxMessageDialog(this, _L("The selected file") + ":\n" + filename + "\n" + _L("does not contain valid gcode."),
|
||||
MessageDialog(this, _L("The selected file") + ":\n" + filename + "\n" + _L("does not contain valid gcode."),
|
||||
wxString(GCODEVIEWER_APP_NAME) + " - " + _L("Error while loading .gcode file"), wxOK | wxICON_WARNING | wxCENTRE).ShowModal();
|
||||
@ -6646,6 +6663,11 @@ void Plater::set_bed_shape(const Pointfs& shape, const double max_print_height,
|
||||
p->set_bed_shape(shape, max_print_height, custom_texture, custom_model, force_as_custom);
|
||||
}
|
||||
|
||||
void Plater::set_default_bed_shape() const
|
||||
{
|
||||
set_bed_shape({ { 0.0, 0.0 }, { 200.0, 0.0 }, { 200.0, 200.0 }, { 0.0, 200.0 } }, 0.0, {}, {}, true);
|
||||
}
|
||||
|
||||
void Plater::force_filament_colors_update()
|
||||
{
|
||||
bool update_scheduled = false;
|
||||
|
@ -399,6 +399,7 @@ public:
|
||||
|
||||
void set_bed_shape() const;
|
||||
void set_bed_shape(const Pointfs& shape, const double max_print_height, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom = false) const;
|
||||
void set_default_bed_shape() const;
|
||||
|
||||
NotificationManager * get_notification_manager();
|
||||
const NotificationManager * get_notification_manager() const;
|
||||
|
Loading…
Reference in New Issue
Block a user