mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-09 18:27:00 +00:00
Merge pull request #153 from Snapmaker/dev_2.3.0_alves
feature add tips for import failed.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include "DownloadManager.hpp"
|
#include "DownloadManager.hpp"
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
|
#include "libslic3r/Utils.hpp"
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/nowide/fstream.hpp>
|
#include <boost/nowide/fstream.hpp>
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
@@ -257,6 +258,8 @@ void DownloadManager::start_download_impl(std::shared_ptr<DownloadTask> task) {
|
|||||||
if (!file.is_open()) {
|
if (!file.is_open()) {
|
||||||
std::string error_msg = "Failed to open file for writing: " + task->dest_path;
|
std::string error_msg = "Failed to open file for writing: " + task->dest_path;
|
||||||
BOOST_LOG_TRIVIAL(error) << "DownloadManager: " << error_msg;
|
BOOST_LOG_TRIVIAL(error) << "DownloadManager: " << error_msg;
|
||||||
|
// Flush logs immediately for critical errors
|
||||||
|
Slic3r::flush_logs();
|
||||||
send_error_update(task, error_msg);
|
send_error_update(task, error_msg);
|
||||||
cleanup_task(task->task_id);
|
cleanup_task(task->task_id);
|
||||||
return;
|
return;
|
||||||
@@ -266,6 +269,8 @@ void DownloadManager::start_download_impl(std::shared_ptr<DownloadTask> task) {
|
|||||||
if (file.fail()) {
|
if (file.fail()) {
|
||||||
std::string error_msg = "Failed to write file: " + task->dest_path;
|
std::string error_msg = "Failed to write file: " + task->dest_path;
|
||||||
BOOST_LOG_TRIVIAL(error) << "DownloadManager: " << error_msg << ", body size: " << body.size();
|
BOOST_LOG_TRIVIAL(error) << "DownloadManager: " << error_msg << ", body size: " << body.size();
|
||||||
|
// Flush logs immediately for critical errors
|
||||||
|
Slic3r::flush_logs();
|
||||||
file.close();
|
file.close();
|
||||||
send_error_update(task, error_msg);
|
send_error_update(task, error_msg);
|
||||||
cleanup_task(task->task_id);
|
cleanup_task(task->task_id);
|
||||||
@@ -280,6 +285,8 @@ void DownloadManager::start_download_impl(std::shared_ptr<DownloadTask> task) {
|
|||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
std::string error_msg = std::string("File write exception: ") + e.what();
|
std::string error_msg = std::string("File write exception: ") + e.what();
|
||||||
BOOST_LOG_TRIVIAL(error) << "DownloadManager: " << error_msg << ", file: " << task->dest_path;
|
BOOST_LOG_TRIVIAL(error) << "DownloadManager: " << error_msg << ", file: " << task->dest_path;
|
||||||
|
// Flush logs immediately for critical errors
|
||||||
|
Slic3r::flush_logs();
|
||||||
send_error_update(task, error_msg);
|
send_error_update(task, error_msg);
|
||||||
cleanup_task(task->task_id);
|
cleanup_task(task->task_id);
|
||||||
}
|
}
|
||||||
@@ -301,6 +308,8 @@ void DownloadManager::start_download_impl(std::shared_ptr<DownloadTask> task) {
|
|||||||
<< ", URL: " << task->file_url
|
<< ", URL: " << task->file_url
|
||||||
<< ", file: " << task->file_name
|
<< ", file: " << task->file_name
|
||||||
<< ", dest: " << task->dest_path;
|
<< ", dest: " << task->dest_path;
|
||||||
|
// Flush logs immediately for critical errors to ensure they are written
|
||||||
|
Slic3r::flush_logs();
|
||||||
task->state = DownloadTaskState::Error;
|
task->state = DownloadTaskState::Error;
|
||||||
task->error_message = error;
|
task->error_message = error;
|
||||||
send_error_update(task, error);
|
send_error_update(task, error);
|
||||||
|
|||||||
@@ -355,6 +355,7 @@ void GenericDownloadDialog::on_download_error(size_t task_id, const std::string&
|
|||||||
|
|
||||||
void GenericDownloadDialog::on_retry_clicked(wxCommandEvent& event)
|
void GenericDownloadDialog::on_retry_clicked(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
|
SetTitle(m_title);
|
||||||
if (m_on_retry) {
|
if (m_on_retry) {
|
||||||
m_on_retry();
|
m_on_retry();
|
||||||
}
|
}
|
||||||
@@ -399,6 +400,8 @@ void GenericDownloadDialog::show_error_page(const std::string& error_msg)
|
|||||||
{
|
{
|
||||||
m_simplebook_status->SetSelection(2);
|
m_simplebook_status->SetSelection(2);
|
||||||
|
|
||||||
|
SetTitle(_L("Donwload failed"));
|
||||||
|
|
||||||
// Display simple error message: filename + "Download failed"
|
// Display simple error message: filename + "Download failed"
|
||||||
wxString filename = wxString::FromUTF8(m_file_name.c_str());
|
wxString filename = wxString::FromUTF8(m_file_name.c_str());
|
||||||
wxString error_text = filename + " - Download failed";
|
wxString error_text = filename + " - Download failed";
|
||||||
|
|||||||
@@ -4038,6 +4038,12 @@ void MainFrame::downloadOpenProject(const std::string& fileUrl, const std::strin
|
|||||||
wxGetApp().mainframe->plater()->load_project(wx_file_path);
|
wxGetApp().mainframe->plater()->load_project(wx_file_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
|
MessageDialog(this, msg, _L("Invalid File"), wxOK | wxICON_WARNING).ShowModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user