From 1eadb6a1a937624b9bbfc33e6e4e2e4589c0e68c Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Mon, 14 Sep 2020 18:01:25 +0200 Subject: [PATCH] Replaced some of Slic3r::RuntimeError exceptions with Slic3r::SlicingError. Only Slic3r::SlicingError are now displayed by a notification, other exceptions are shown by a pop-up dialog. --- src/libslic3r/Fill/FillBase.cpp | 1 - src/libslic3r/Print.cpp | 2 +- src/libslic3r/PrintObject.cpp | 4 ++-- src/libslic3r/SLAPrintSteps.cpp | 8 ++++---- src/slic3r/GUI/Plater.cpp | 11 +++++++++-- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/libslic3r/Fill/FillBase.cpp b/src/libslic3r/Fill/FillBase.cpp index b0319efde..077555d2c 100644 --- a/src/libslic3r/Fill/FillBase.cpp +++ b/src/libslic3r/Fill/FillBase.cpp @@ -2,7 +2,6 @@ #include "../ClipperUtils.hpp" #include "../EdgeGrid.hpp" -#include "../Exception.hpp" #include "../Geometry.hpp" #include "../Surface.hpp" #include "../PrintConfig.hpp" diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index a73b7016f..a82ab3ddd 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1604,7 +1604,7 @@ void Print::process() // Initialize the tool ordering, so it could be used by the G-code preview slider for planning tool changes and filament switches. m_tool_ordering = ToolOrdering(*this, -1, false); if (m_tool_ordering.empty() || m_tool_ordering.last_extruder() == unsigned(-1)) - throw Slic3r::RuntimeError("The print is empty. The model is not printable with current print settings."); + throw Slic3r::SlicingError("The print is empty. The model is not printable with current print settings."); } this->set_done(psWipeTower); } diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 30c070338..ddd41af01 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -139,7 +139,7 @@ void PrintObject::slice() } }); if (m_layers.empty()) - throw Slic3r::RuntimeError("No layers were detected. You might want to repair your STL file(s) or check their size or thickness and retry.\n"); + throw Slic3r::SlicingError("No layers were detected. You might want to repair your STL file(s) or check their size or thickness and retry.\n"); this->set_done(posSlice); } @@ -427,7 +427,7 @@ void PrintObject::generate_support_material() // therefore they cannot be printed without supports. for (const Layer *layer : m_layers) if (layer->empty()) - throw Slic3r::RuntimeError("Levitating objects cannot be printed without supports."); + throw Slic3r::SlicingError("Levitating objects cannot be printed without supports."); #endif } this->set_done(posSupportMaterial); diff --git a/src/libslic3r/SLAPrintSteps.cpp b/src/libslic3r/SLAPrintSteps.cpp index 19bd85488..d94bc682b 100644 --- a/src/libslic3r/SLAPrintSteps.cpp +++ b/src/libslic3r/SLAPrintSteps.cpp @@ -188,7 +188,7 @@ void SLAPrint::Steps::drill_holes(SLAPrintObject &po) } if (MeshBoolean::cgal::does_self_intersect(*holes_mesh_cgal)) - throw Slic3r::RuntimeError(L("Too many overlapping holes.")); + throw Slic3r::SlicingError(L("Too many overlapping holes.")); auto hollowed_mesh_cgal = MeshBoolean::cgal::triangle_mesh_to_cgal(hollowed_mesh); @@ -196,7 +196,7 @@ void SLAPrint::Steps::drill_holes(SLAPrintObject &po) MeshBoolean::cgal::minus(*hollowed_mesh_cgal, *holes_mesh_cgal); hollowed_mesh = MeshBoolean::cgal::cgal_to_triangle_mesh(*hollowed_mesh_cgal); } catch (const std::runtime_error &) { - throw Slic3r::RuntimeError(L( + throw Slic3r::SlicingError(L( "Drilling holes into the mesh failed. " "This is usually caused by broken model. Try to fix it first.")); } @@ -446,7 +446,7 @@ void SLAPrint::Steps::generate_pad(SLAPrintObject &po) { auto &pad_mesh = po.m_supportdata->support_tree_ptr->retrieve_mesh(sla::MeshType::Pad); if (!validate_pad(pad_mesh, pcfg)) - throw Slic3r::RuntimeError( + throw Slic3r::SlicingError( L("No pad can be generated for this model with the " "current configuration")); @@ -614,7 +614,7 @@ void SLAPrint::Steps::initialize_printer_input() for(const SliceRecord& slicerecord : o->get_slice_index()) { if (!slicerecord.is_valid()) - throw Slic3r::RuntimeError( + throw Slic3r::SlicingError( L("There are unprintable objects. Try to " "adjust support settings to make the " "objects printable.")); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 6d856960d..ec632611f 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3524,8 +3524,15 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt) if (evt.error()) { std::string message = evt.format_error_message(); - //FIXME show a messagebox if evt.critical_error(). - notification_manager->push_slicing_error_notification(message, *q->get_current_canvas3D()); + if (evt.critical_error()) { + if (q->m_tracking_popup_menu) + // We don't want to pop-up a message box when tracking a pop-up menu. + // We postpone the error message instead. + q->m_tracking_popup_menu_error_message = message; + else + show_error(q, message); + } else + notification_manager->push_slicing_error_notification(message, *q->get_current_canvas3D()); this->statusbar()->set_status_text(from_u8(message)); const wxString invalid_str = _L("Invalid data"); for (auto btn : { ActionButtonType::abReslice, ActionButtonType::abSendGCode, ActionButtonType::abExport })