diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index eb30163753..c910653d16 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -3841,9 +3841,18 @@ bool to_xml(std::stringstream &stream, const EmbossShape::SvgFile &svg, const Mo stream << SVG_FILE_PATH_ATTR << "=\"" << xml_escape_double_quotes_attribute_value(svg.path) << "\" "; stream << SVG_FILE_PATH_IN_3MF_ATTR << "=\"" << xml_escape_double_quotes_attribute_value(svg.path_in_3mf) << "\" "; - const std::string &file_data = *svg.file_data; + std::shared_ptr file_data = svg.file_data; + assert(file_data != nullptr); + if (file_data == nullptr && !svg.path.empty()) + file_data = read_from_disk(svg.path); + if (file_data == nullptr) { + BOOST_LOG_TRIVIAL(warning) << "Can't write svg file no filedata"; + return false; + } + const std::string &file_data_str = *file_data; + return mz_zip_writer_add_mem(&archive, svg.path_in_3mf.c_str(), - (const void *) file_data.c_str(), file_data.size(), MZ_DEFAULT_COMPRESSION); + (const void *) file_data_str.c_str(), file_data_str.size(), MZ_DEFAULT_COMPRESSION); } } // namespace diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp index 6f61ff6fc3..61d18d316c 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp @@ -1340,6 +1340,8 @@ void GLGizmoSVG::draw_window() return; } + assert(m_volume->emboss_shape->svg_file.file_data != nullptr); + draw_preview(); draw_filename(); @@ -1517,7 +1519,8 @@ void GLGizmoSVG::draw_filename(){ // set .svg_file.path_in_3mf to remember file name m_volume->emboss_shape->svg_file.path.clear(); m_volume_shape.svg_file.path.clear(); - m_filename_preview.clear(); + // TRN - Preview of filename after clear local filepath. + m_filename_preview = _u8L("No-name SVG"); } else if (ImGui::IsItemHovered()) { ImGui::SetTooltip("%s", _u8L("Do NOT save local path to 3MF file.\n" "Also disables 'reload from disk' option.").c_str());