diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index 4f9f9ad1e8..a239224262 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -150,15 +150,15 @@ public: Layer* get_layer(int idx) { return m_layers[idx]; } // Get a layer exactly at print_z. const Layer* get_layer_at_printz(coordf_t print_z) const { - auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [print_z](const Layer *layer) { return layer->print_z < print_z; }); + auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [print_z](const Layer *layer) { return layer->print_z < print_z; }); return (it == m_layers.end() || (*it)->print_z != print_z) ? nullptr : *it; } Layer* get_layer_at_printz(coordf_t print_z) { return const_cast(std::as_const(*this).get_layer_at_printz(print_z)); } // Get a layer approximately at print_z. const Layer* get_layer_at_printz(coordf_t print_z, coordf_t epsilon) const { - coordf_t limit = print_z + epsilon; - auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [limit](const Layer *layer) { return layer->print_z < limit; }); - return (it == m_layers.end() || (*it)->print_z < print_z - epsilon) ? nullptr : *it; + coordf_t limit = print_z - epsilon; + auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [limit](const Layer *layer) { return layer->print_z < limit; }); + return (it == m_layers.end() || (*it)->print_z > print_z + epsilon) ? nullptr : *it; } Layer* get_layer_at_printz(coordf_t print_z, coordf_t epsilon) { return const_cast(std::as_const(*this).get_layer_at_printz(print_z, epsilon)); } diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.cpp b/src/slic3r/GUI/BackgroundSlicingProcess.cpp index 53c3ec5ea2..27aa6eaa6d 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp @@ -103,30 +103,25 @@ void BackgroundSlicingProcess::process_fff() GUI::RemovableDriveManager::get_instance().update(); bool with_check = GUI::RemovableDriveManager::get_instance().is_path_on_removable_drive(export_path); int copy_ret_val = copy_file(m_temp_output_path, export_path, with_check); - if (with_check && copy_ret_val == -2) - { - std::string err_msg = "Copying of the temporary G-code to the output G-code failed. There might be problem with target device, please try exporting again or using different device. The corrupted output G-code is at " + export_path + ".tmp."; - throw std::runtime_error(_utf8(L(err_msg))); - } - else if (with_check && copy_ret_val == -4) - { - std::string err_msg = "Copying of the temporary G-code has finnished but the original code at "+ m_temp_output_path +" couldn't be opened during copy check. The output G-code is at " + export_path + ".tmp."; - throw std::runtime_error(_utf8(L(err_msg))); - } - else if (with_check && copy_ret_val == -5) - { - std::string err_msg = "Copying of the temporary G-code has finnished but the exported code couldn't be opened during copy check. The output G-code is at " + export_path + ".tmp."; - throw std::runtime_error(_utf8(L(err_msg))); - } - else if (copy_ret_val == -3) - { - std::string err_msg = "Renaming of the G-code after copying to the selected destination folder has failed. Current path is " + export_path + ".tmp. Please try exporting again."; - throw std::runtime_error(_utf8(L(err_msg))); - } - else if ( copy_ret_val != 0) - { - throw std::runtime_error(_utf8(L("Copying of the temporary G-code to the output G-code failed. Maybe the SD card is write locked?"))); + switch (copy_ret_val){ + case 0: break; // no error + case -2: + throw std::runtime_error((boost::format(_utf8(L("Copying of the temporary G-code to the output G-code failed. There might be problem with target device, please try exporting again or using different device. The corrupted output G-code is at %1%.tmp."))) % export_path).str()); + break; + case -3: + throw std::runtime_error((boost::format(_utf8(L("Renaming of the G-code after copying to the selected destination folder has failed. Current path is %1%.tmp. Please try exporting again."))) % export_path).str()); + break; + case -4: + throw std::runtime_error((boost::format(_utf8(L("Copying of the temporary G-code has finished but the original code at %1% couldn't be opened during copy check. The output G-code is at %2%.tmp."))) % m_temp_output_path % export_path).str()); + break; + case -5: + throw std::runtime_error((boost::format(_utf8(L("Copying of the temporary G-code has finished but the exported code couldn't be opened during copy check. The output G-code is at %1%.tmp."))) % export_path).str()); + break; + default: + throw std::runtime_error(_utf8(L("Copying of the temporary G-code to the output G-code failed. Maybe the SD card is write locked?"))); + break; } + m_print->set_status(95, _utf8(L("Running post-processing scripts"))); run_post_process_scripts(export_path, m_fff_print->config()); m_print->set_status(100, (boost::format(_utf8(L("G-code file exported to %1%"))) % export_path).str()); diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index a5566de299..f5f5548309 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -77,7 +77,9 @@ static int extruders_count() static void take_snapshot(const wxString& snapshot_name) { - wxGetApp().plater()->take_snapshot(snapshot_name); + Plater* plater = wxGetApp().plater(); + if (plater) + plater->take_snapshot(snapshot_name); } ObjectList::ObjectList(wxWindow* parent) : @@ -3931,7 +3933,9 @@ void ObjectList::OnEditingDone(wxDataViewEvent &event) m_last_selected_column = -1; #endif //__WXMSW__ - wxGetApp().plater()->set_current_canvas_as_dirty(); + Plater* plater = wxGetApp().plater(); + if (plater) + plater->set_current_canvas_as_dirty(); } void ObjectList::show_multi_selection_menu() diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index e0cfe5be65..541be423d0 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2795,7 +2795,7 @@ void Tab::select_preset(std::string preset_name, bool delete_current) if (! canceled) { // The preset will be switched to a different, compatible preset, or the '-- default --'. m_dependent_tabs.emplace_back((printer_technology == ptFFF) ? Preset::Type::TYPE_FILAMENT : Preset::Type::TYPE_SLA_MATERIAL); - if (old_preset_dirty) + if (old_preset_dirty && ! new_preset_compatible) dependent.discard_current_changes(); } } else if (printer_tab) {