From 1a4ce039daae5d944a48c91df614db6a47b30a60 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 13 Apr 2022 10:51:31 +0200 Subject: [PATCH] Fix of #8175: crash with Import SL1 in some cases - do not process non-existing file, report as error - cancelling the dialog is not an error, but a check in finalize() is needed - fixed some localization issues (serious btw: the ToStdString returned "" in one of the cases, which would in turn ignore the error and proceed as if if did not happen) - reset err in reset(), just to be sure --- src/slic3r/GUI/Jobs/SLAImportJob.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/Jobs/SLAImportJob.cpp b/src/slic3r/GUI/Jobs/SLAImportJob.cpp index 0d42cec2d3..8377ddc73e 100644 --- a/src/slic3r/GUI/Jobs/SLAImportJob.cpp +++ b/src/slic3r/GUI/Jobs/SLAImportJob.cpp @@ -141,7 +141,7 @@ void SLAImportJob::process() return !was_canceled(); }; - if (p->path.empty()) return; + if (p->path.empty() || ! p->err.empty()) return; std::string path = p->path.ToUTF8().data(); try { @@ -155,8 +155,8 @@ void SLAImportJob::process() break; } } catch (MissingProfileError &) { - p->err = _L("The SLA archive doesn't contain any presets. " - "Please activate some SLA printer preset first before importing that SLA archive.").ToStdString(); + p->err = _u8L("The SLA archive doesn't contain any presets. " + "Please activate some SLA printer preset first before importing that SLA archive."); } catch (std::exception &ex) { p->err = ex.what(); } @@ -172,6 +172,7 @@ void SLAImportJob::reset() p->profile = m_plater->sla_print().full_print_config(); p->win = {2, 2}; p->path.Clear(); + p->err = ""; } void SLAImportJob::prepare() @@ -182,6 +183,10 @@ void SLAImportJob::prepare() auto path = p->import_dlg.get_path(); auto nm = wxFileName(path); p->path = !nm.Exists(wxFILE_EXISTS_REGULAR) ? "" : nm.GetFullPath(); + if (p->path.empty()) { + p->err = _u8L("The file does not exist."); + return; + } p->sel = p->import_dlg.get_selection(); p->win = p->import_dlg.get_marchsq_windowsize(); p->config_substitutions.clear(); @@ -201,14 +206,20 @@ void SLAImportJob::finalize() return; } + if (p->path.empty()) { + // This happens when the user cancels the import dialog. That is not + // an error to report, but we cannot continue either. + return; + } + std::string name = wxFileName(p->path).GetName().ToUTF8().data(); if (p->profile.empty()) { m_plater->get_notification_manager()->push_notification( NotificationType::CustomNotification, NotificationManager::NotificationLevel::WarningNotificationLevel, - _L("The imported SLA archive did not contain any presets. " - "The current SLA presets were used as fallback.").ToStdString()); + _u8L("The imported SLA archive did not contain any presets. " + "The current SLA presets were used as fallback.")); } if (p->sel != Sel::modelOnly) {