mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-03 01:00:37 +08:00
Hot fix for storing SVG into 3mf to prevent crash
This commit is contained in:
parent
1d89f1ad52
commit
89cc01f3a9
@ -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_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) << "\" ";
|
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<std::string> 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(),
|
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
|
} // namespace
|
||||||
|
@ -1340,6 +1340,8 @@ void GLGizmoSVG::draw_window()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(m_volume->emboss_shape->svg_file.file_data != nullptr);
|
||||||
|
|
||||||
draw_preview();
|
draw_preview();
|
||||||
draw_filename();
|
draw_filename();
|
||||||
|
|
||||||
@ -1517,7 +1519,8 @@ void GLGizmoSVG::draw_filename(){
|
|||||||
// set .svg_file.path_in_3mf to remember file name
|
// set .svg_file.path_in_3mf to remember file name
|
||||||
m_volume->emboss_shape->svg_file.path.clear();
|
m_volume->emboss_shape->svg_file.path.clear();
|
||||||
m_volume_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()) {
|
} else if (ImGui::IsItemHovered()) {
|
||||||
ImGui::SetTooltip("%s", _u8L("Do NOT save local path to 3MF file.\n"
|
ImGui::SetTooltip("%s", _u8L("Do NOT save local path to 3MF file.\n"
|
||||||
"Also disables 'reload from disk' option.").c_str());
|
"Also disables 'reload from disk' option.").c_str());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user