diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 5db1ead689..b8b78ce273 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -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 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(); if (res != wxID_OK) @@ -3930,7 +3939,7 @@ void MainFrame::downloadOpenProject(const std::string& fileUrl, const std::strin if (completeFilePath.empty()) { auto downloadPath = wxGetApp().app_config->get("download_path"); - completeFilePath = downloadPath + "/" + fileName; + completeFilePath = downloadPath + "/" + releaFileName; } if (!boost::filesystem::exists(completeFilePath)) { @@ -3951,7 +3960,7 @@ void MainFrame::downloadOpenProject(const std::string& fileUrl, const std::strin else { // 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(); } diff --git a/src/slic3r/GUI/SSWCP.cpp b/src/slic3r/GUI/SSWCP.cpp index d459f4504c..075fe3a0b3 100644 --- a/src/slic3r/GUI/SSWCP.cpp +++ b/src/slic3r/GUI/SSWCP.cpp @@ -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() : ""; 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; } // Use Download Manager DownloadManager* download_mgr = wxGetApp().download_manager(); if (!download_mgr) { - handle_general_fail(-1, "Download Manager not available"); + handle_general_fail(-1, wxString::FromUTF8("Download Manager not available")); 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 self = + std::static_pointer_cast(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; - m_msg = "success"; - send_to_js(); - finish_job(); - - } catch (std::exception& e) { - handle_general_fail(-1, e.what()); + } catch (const std::exception& e) { + handle_general_fail(-1, wxString::FromUTF8(e.what())); } }