mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-13 07:29:04 +08:00
Merge branch 'lm_invalid_3mf_crash_SPE-2135' into master_27x
This commit is contained in:
commit
11f61037a4
@ -706,12 +706,20 @@ namespace Slic3r {
|
||||
m_name = boost::filesystem::path(filename).stem().string();
|
||||
|
||||
// we first loop the entries to read from the archive the .model file only, in order to extract the version from it
|
||||
bool found_model = false;
|
||||
for (mz_uint i = 0; i < num_entries; ++i) {
|
||||
if (mz_zip_reader_file_stat(&archive, i, &stat)) {
|
||||
std::string name(stat.m_filename);
|
||||
std::replace(name.begin(), name.end(), '\\', '/');
|
||||
|
||||
if (boost::algorithm::istarts_with(name, MODEL_FOLDER) && boost::algorithm::iends_with(name, MODEL_EXTENSION)) {
|
||||
if (boost::algorithm::iends_with(name, MODEL_EXTENSION)) {
|
||||
if(found_model){
|
||||
close_zip_reader(&archive);
|
||||
add_error("3mf contain multiple .model files and it is not supported yet.");
|
||||
return false;
|
||||
}
|
||||
found_model = true;
|
||||
|
||||
try
|
||||
{
|
||||
// valid model name -> extract model
|
||||
@ -730,6 +738,11 @@ namespace Slic3r {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found_model) {
|
||||
close_zip_reader(&archive);
|
||||
add_error("Not valid 3mf. There is missing .model file.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// we then loop again the entries to read other files stored in the archive
|
||||
for (mz_uint i = 0; i < num_entries; ++i) {
|
||||
@ -3574,11 +3587,11 @@ bool load_3mf(const char* path, DynamicPrintConfig& config, ConfigSubstitutionCo
|
||||
// All import should use "C" locales for number formatting.
|
||||
CNumericLocalesSetter locales_setter;
|
||||
_3MF_Importer importer;
|
||||
importer.load_model_from_file(path, *model, config, config_substitutions, check_version);
|
||||
bool res = importer.load_model_from_file(path, *model, config, config_substitutions, check_version);
|
||||
importer.log_errors();
|
||||
handle_legacy_project_loaded(importer.version(), config, importer.prusaslicer_generator_version());
|
||||
|
||||
return !model->objects.empty() || !config.empty();
|
||||
return res;
|
||||
}
|
||||
|
||||
bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, bool fullpath_sources, const ThumbnailData* thumbnail_data, bool zip64)
|
||||
|
Loading…
x
Reference in New Issue
Block a user