mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-11 02:57:39 +00:00
Fix: issue of gcode.3mf's filename
This commit is contained in:
@@ -3921,8 +3921,17 @@ void MainFrame::downloadOpenProject(const std::string& fileUrl, const std::strin
|
|||||||
{
|
{
|
||||||
// std::string fileUrl = "https://public.resource.snapmaker.com/model/public/3mf/test_for_download.3mf";
|
// std::string fileUrl = "https://public.resource.snapmaker.com/model/public/3mf/test_for_download.3mf";
|
||||||
// std::string filename = "test_for_download.3mf";
|
// std::string filename = "test_for_download.3mf";
|
||||||
|
wxString fileNameEx = wxString::FromUTF8(fileName.c_str()).Lower();
|
||||||
|
std::string releaFileName = "";
|
||||||
|
|
||||||
GenericDownloadDialog dlg(_L("downloading the model"), fileUrl, fileName, completeFilePath);
|
bool strRes = fileNameEx.EndsWith(".3mf");
|
||||||
|
|
||||||
|
if (strRes)
|
||||||
|
releaFileName = fileName;
|
||||||
|
else
|
||||||
|
releaFileName = fileName + ".3mf";
|
||||||
|
|
||||||
|
GenericDownloadDialog dlg(_L("downloading the model"), fileUrl, releaFileName, completeFilePath);
|
||||||
auto res = dlg.ShowModal();
|
auto res = dlg.ShowModal();
|
||||||
|
|
||||||
if (res != wxID_OK)
|
if (res != wxID_OK)
|
||||||
@@ -3930,7 +3939,7 @@ void MainFrame::downloadOpenProject(const std::string& fileUrl, const std::strin
|
|||||||
|
|
||||||
if (completeFilePath.empty()) {
|
if (completeFilePath.empty()) {
|
||||||
auto downloadPath = wxGetApp().app_config->get("download_path");
|
auto downloadPath = wxGetApp().app_config->get("download_path");
|
||||||
completeFilePath = downloadPath + "/" + fileName;
|
completeFilePath = downloadPath + "/" + releaFileName;
|
||||||
}
|
}
|
||||||
if (!boost::filesystem::exists(completeFilePath))
|
if (!boost::filesystem::exists(completeFilePath))
|
||||||
{
|
{
|
||||||
@@ -3951,7 +3960,7 @@ void MainFrame::downloadOpenProject(const std::string& fileUrl, const std::strin
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Not a valid 3mf file, show error message
|
// Not a valid 3mf file, show error message
|
||||||
wxString msg = wxString::Format(_L("The downloaded file '%s' is not a valid 3MF project file."), fileName);
|
wxString msg = wxString::Format(_L("The downloaded file '%s' is not a valid 3MF project file."), releaFileName);
|
||||||
MessageDialog(this, msg, _L("Invalid File"), wxOK | wxICON_WARNING).ShowModal();
|
MessageDialog(this, msg, _L("Invalid File"), wxOK | wxICON_WARNING).ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4386,26 +4386,40 @@ void SSWCP_UserLogin_Instance::sw_DownloadFileAndOpen()
|
|||||||
std::string fileUrl = m_param_data.count("file_url") ? m_param_data["file_url"].get<std::string>() : "";
|
std::string fileUrl = m_param_data.count("file_url") ? m_param_data["file_url"].get<std::string>() : "";
|
||||||
|
|
||||||
if (fileUrl.empty() || fileName.empty()) {
|
if (fileUrl.empty() || fileName.empty()) {
|
||||||
handle_general_fail(-1, "file_url and file_name are required");
|
handle_general_fail(-1, wxString::FromUTF8("file_url and file_name are required"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use Download Manager
|
// Use Download Manager
|
||||||
DownloadManager* download_mgr = wxGetApp().download_manager();
|
DownloadManager* download_mgr = wxGetApp().download_manager();
|
||||||
if (!download_mgr) {
|
if (!download_mgr) {
|
||||||
handle_general_fail(-1, "Download Manager not available");
|
handle_general_fail(-1, wxString::FromUTF8("Download Manager not available"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGetApp().mainframe->downloadOpenProject(fileUrl, fileName, "");
|
// WebView script message runs inside the webview event handler; calling ShowModal() synchronously
|
||||||
|
// (via GenericDownloadDialog in downloadOpenProject) causes re-entrancy / crashes on Windows.
|
||||||
|
// Defer to the next event-loop iteration — same pattern as sw_UserLogin().
|
||||||
|
std::shared_ptr<SSWCP_UserLogin_Instance> self =
|
||||||
|
std::static_pointer_cast<SSWCP_UserLogin_Instance>(shared_from_this());
|
||||||
|
wxGetApp().CallAfter([self, fileUrl, fileName]() {
|
||||||
|
if (!wxGetApp().mainframe) {
|
||||||
|
self->handle_general_fail(-1, wxString::FromUTF8("Main window not available"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
wxGetApp().mainframe->downloadOpenProject(fileUrl, fileName, "");
|
||||||
|
self->m_status = 0;
|
||||||
|
self->m_msg = "success";
|
||||||
|
self->send_to_js();
|
||||||
|
self->finish_job();
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
self->handle_general_fail(-1, wxString::FromUTF8(e.what()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
m_status = 0;
|
} catch (const std::exception& e) {
|
||||||
m_msg = "success";
|
handle_general_fail(-1, wxString::FromUTF8(e.what()));
|
||||||
send_to_js();
|
|
||||||
finish_job();
|
|
||||||
|
|
||||||
} catch (std::exception& e) {
|
|
||||||
handle_general_fail(-1, e.what());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user