From 4b6fe6108310077a4676a83d40aa9b423b0967de Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Tue, 28 Mar 2023 10:58:07 +0200 Subject: [PATCH] Prevent crash if archive format is invalid Throw exception instead and display it's error message --- src/libslic3r/SLAPrint.cpp | 9 +++++++++ src/libslic3r/SLAPrint.hpp | 5 +---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 6dc4a46206..8238a266ee 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -588,6 +588,15 @@ std::string SLAPrint::validate(std::string*) const return ""; } +void SLAPrint::export_print(const std::string &fname, const ThumbnailsList &thumbnails, const std::string &projectname) +{ + if (m_archiver) + m_archiver->export_print(fname, *this, thumbnails, projectname); + else { + throw ExportError(format(_u8L("Unknown archive format: %s"), m_printer_config.sla_archive_format.value)); + } +} + bool SLAPrint::invalidate_step(SLAPrintStep step) { bool invalidated = Inherited::invalidate_step(step); diff --git a/src/libslic3r/SLAPrint.hpp b/src/libslic3r/SLAPrint.hpp index bd8424ca78..126941d820 100644 --- a/src/libslic3r/SLAPrint.hpp +++ b/src/libslic3r/SLAPrint.hpp @@ -546,10 +546,7 @@ public: void export_print(const std::string &fname, const ThumbnailsList &thumbnails, - const std::string &projectname = "") - { - m_archiver->export_print(fname, *this, thumbnails, projectname); - } + const std::string &projectname = ""); private: