mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-29 12:58:03 +00:00
Fix Windows crash after using "Replace all with 3D files" (#15102)
Fix Windows crash in Replace all with 3D file Keep the replacement result message as wxString and substitute the volume name directly. On Windows, wxString::ToStdString() cannot encode the Unicode status icon through the active ANSI code page and returns an empty string. Passing that empty string to boost::format with a volume-name argument throws boost::too_many_args and exits OrcaSlicer.
This commit is contained in:
@@ -9501,7 +9501,7 @@ void Plater::priv::replace_all_with_stl()
|
||||
return;
|
||||
}
|
||||
|
||||
std::string status = _L("Replaced with 3D files from directory:\n").ToStdString() + out_path.string() + "\n\n";
|
||||
wxString status = _L("Replaced with 3D files from directory:\n") + from_u8(out_path.string()) + "\n\n";
|
||||
|
||||
for (unsigned int idx : volume_idxs) {
|
||||
const GLVolume* v = selection.get_volume(idx);
|
||||
@@ -9521,13 +9521,13 @@ void Plater::priv::replace_all_with_stl()
|
||||
std::string volume_name = volume->name;
|
||||
|
||||
if (new_path == input_path) {
|
||||
status += boost::str(boost::format(_L("✖ Skipped %1%: same file.\n").ToStdString()) % volume_name);
|
||||
status += wxString::Format(_L("✖ Skipped %s: same file.\n"), from_u8(volume_name));
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " skipping replace volume : same filename " << new_path;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!fs::exists(new_path)) {
|
||||
status += boost::str(boost::format(_L("✖ Skipped %1%: file does not exist.\n").ToStdString()) % volume_name);
|
||||
status += wxString::Format(_L("✖ Skipped %s: file does not exist.\n"), from_u8(volume_name));
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " cannot replace volume : filen does not exist " << new_path;
|
||||
continue;
|
||||
}
|
||||
@@ -9535,12 +9535,12 @@ void Plater::priv::replace_all_with_stl()
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " replacing volume : " << input_path << " with " << new_path;
|
||||
|
||||
if (!replace_volume_with_stl(object_idx, volume_idx, new_path, _u8L("Replace with 3D file"))) {
|
||||
status += boost::str(boost::format(_L("✖ Skipped %1%: failed to replace.\n").ToStdString()) % volume_name);
|
||||
status += wxString::Format(_L("✖ Skipped %s: failed to replace.\n"), from_u8(volume_name));
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " cannot replace volume : failed to replace with " << new_path;
|
||||
continue;
|
||||
}
|
||||
|
||||
status += boost::str(boost::format(_L("✔ Replaced %1%.\n").ToStdString()) % volume_name);
|
||||
status += wxString::Format(_L("✔ Replaced %s.\n"), from_u8(volume_name));
|
||||
}
|
||||
|
||||
// update 3D scene
|
||||
|
||||
Reference in New Issue
Block a user