mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-03 01:10:35 +08:00
Merge branch 'lm_jb_osx_quick_quit_crash_fix' (SPE-2560)
This commit is contained in:
commit
fac23c17d2
@ -714,9 +714,9 @@ void MainFrame::init_tabpanel()
|
|||||||
});
|
});
|
||||||
|
|
||||||
m_plater = new Plater(this, this);
|
m_plater = new Plater(this, this);
|
||||||
|
wxGetApp().plater_ = m_plater;
|
||||||
m_plater->Hide();
|
m_plater->Hide();
|
||||||
|
|
||||||
wxGetApp().plater_ = m_plater;
|
|
||||||
|
|
||||||
if (wxGetApp().is_editor())
|
if (wxGetApp().is_editor())
|
||||||
create_preset_tabs();
|
create_preset_tabs();
|
||||||
|
@ -182,12 +182,15 @@ std::string escape_path_by_element(const std::string& path_string)
|
|||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_authorization_header(Http& http)
|
bool add_authorization_header(Http& http)
|
||||||
{
|
{
|
||||||
|
if (wxApp::GetInstance() == nullptr || ! GUI::wxGetApp().plater())
|
||||||
|
return false;
|
||||||
const std::string access_token = GUI::wxGetApp().plater()->get_user_account()->get_access_token();
|
const std::string access_token = GUI::wxGetApp().plater()->get_user_account()->get_access_token();
|
||||||
if (!access_token.empty()) {
|
if (!access_token.empty()) {
|
||||||
http.header("Authorization", "Bearer " + access_token);
|
http.header("Authorization", "Bearer " + access_token);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -204,7 +207,8 @@ bool OnlineArchiveRepository::get_file_inner(const std::string& url, const fs::p
|
|||||||
tmp_path.string());
|
tmp_path.string());
|
||||||
|
|
||||||
auto http = Http::get(url);
|
auto http = Http::get(url);
|
||||||
add_authorization_header(http);
|
if (!add_authorization_header(http))
|
||||||
|
return false;
|
||||||
http
|
http
|
||||||
.timeout_max(30)
|
.timeout_max(30)
|
||||||
.on_progress([](Http::Progress, bool& cancel) {
|
.on_progress([](Http::Progress, bool& cancel) {
|
||||||
@ -881,7 +885,8 @@ bool sync_inner(std::string& manifest, PresetUpdaterUIStatus* ui_status)
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
std::string url = Utils::ServiceConfig::instance().preset_repo_repos_url();
|
std::string url = Utils::ServiceConfig::instance().preset_repo_repos_url();
|
||||||
auto http = Http::get(std::move(url));
|
auto http = Http::get(std::move(url));
|
||||||
add_authorization_header(http);
|
if (!add_authorization_header(http))
|
||||||
|
return false;
|
||||||
http
|
http
|
||||||
.timeout_max(30)
|
.timeout_max(30)
|
||||||
.on_error([&](std::string body, std::string error, unsigned http_status) {
|
.on_error([&](std::string body, std::string error, unsigned http_status) {
|
||||||
|
@ -46,10 +46,13 @@ void ProjectDirtyStateManager::update_from_presets()
|
|||||||
|
|
||||||
void ProjectDirtyStateManager::update_from_preview()
|
void ProjectDirtyStateManager::update_from_preview()
|
||||||
{
|
{
|
||||||
|
if (wxApp::GetInstance() == nullptr || wxGetApp().plater() == nullptr)
|
||||||
|
return;
|
||||||
const bool is_dirty = m_initial_custom_gcode_per_print_z != wxGetApp().model().custom_gcode_per_print_z;
|
const bool is_dirty = m_initial_custom_gcode_per_print_z != wxGetApp().model().custom_gcode_per_print_z;
|
||||||
if (m_custom_gcode_per_print_z_dirty != is_dirty) {
|
if (m_custom_gcode_per_print_z_dirty != is_dirty) {
|
||||||
m_custom_gcode_per_print_z_dirty = is_dirty;
|
m_custom_gcode_per_print_z_dirty = is_dirty;
|
||||||
wxGetApp().mainframe->update_title();
|
if (wxApp::GetInstance() != nullptr)
|
||||||
|
wxGetApp().mainframe->update_title();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,8 @@ namespace {
|
|||||||
BOOST_LOG_TRIVIAL(error) << full_message;
|
BOOST_LOG_TRIVIAL(error) << full_message;
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
|
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
|
||||||
evt->SetString(full_message);
|
evt->SetString(full_message);
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
if (wxApp::GetInstance() != nullptr)
|
||||||
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -215,7 +216,8 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d
|
|||||||
BOOST_LOG_TRIVIAL(error) << message;
|
BOOST_LOG_TRIVIAL(error) << message;
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
|
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
|
||||||
evt->SetString(message);
|
evt->SetString(message);
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
if (wxApp::GetInstance() != nullptr)
|
||||||
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
return boost::filesystem::path();
|
return boost::filesystem::path();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,9 +231,11 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d
|
|||||||
std::string line2 = GUI::format(_u8L("Can't create file at %1%"), tmp_path.string());
|
std::string line2 = GUI::format(_u8L("Can't create file at %1%"), tmp_path.string());
|
||||||
std::string message = GUI::format("%1%\n%2%", line1, line2);
|
std::string message = GUI::format("%1%\n%2%", line1, line2);
|
||||||
BOOST_LOG_TRIVIAL(error) << message;
|
BOOST_LOG_TRIVIAL(error) << message;
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
|
if (wxApp::GetInstance() != nullptr) {
|
||||||
evt->SetString(message);
|
wxCommandEvent *evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
evt->SetString(message);
|
||||||
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
|
}
|
||||||
return boost::filesystem::path();
|
return boost::filesystem::path();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,10 +247,12 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d
|
|||||||
if (progress.dltotal > 0 && progress.dltotal > expected_size) {
|
if (progress.dltotal > 0 && progress.dltotal > expected_size) {
|
||||||
std::string message = GUI::format("Downloading new %1% has failed. The file has incorrect file size. Aborting download.\nExpected size: %2%\nDownload size: %3%", SLIC3R_APP_NAME, expected_size, progress.dltotal);
|
std::string message = GUI::format("Downloading new %1% has failed. The file has incorrect file size. Aborting download.\nExpected size: %2%\nDownload size: %3%", SLIC3R_APP_NAME, expected_size, progress.dltotal);
|
||||||
BOOST_LOG_TRIVIAL(error) << message;
|
BOOST_LOG_TRIVIAL(error) << message;
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
|
if (wxApp::GetInstance() != nullptr) {
|
||||||
evt->SetString(message);
|
wxCommandEvent *evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
evt->SetString(message);
|
||||||
return false;
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
} else if (progress.dltotal > 0 && progress.dltotal < expected_size) {
|
} else if (progress.dltotal > 0 && progress.dltotal < expected_size) {
|
||||||
// This is possible error, but we cannot know until the download is finished. Somehow the total size can grow during the download.
|
// This is possible error, but we cannot know until the download is finished. Somehow the total size can grow during the download.
|
||||||
BOOST_LOG_TRIVIAL(info) << GUI::format("Downloading new %1% has incorrect size. The download will continue. \nExpected size: %2%\nDownload size: %3%", SLIC3R_APP_NAME, expected_size, progress.dltotal);
|
BOOST_LOG_TRIVIAL(info) << GUI::format("Downloading new %1% has incorrect size. The download will continue. \nExpected size: %2%\nDownload size: %3%", SLIC3R_APP_NAME, expected_size, progress.dltotal);
|
||||||
@ -256,10 +262,12 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d
|
|||||||
BOOST_LOG_TRIVIAL(debug) << "App download " << gui_progress << "% " << progress.dlnow << " of " << progress.dltotal;
|
BOOST_LOG_TRIVIAL(debug) << "App download " << gui_progress << "% " << progress.dlnow << " of " << progress.dltotal;
|
||||||
if (last_gui_progress < gui_progress && (last_gui_progress != 0 || gui_progress != 100)) {
|
if (last_gui_progress < gui_progress && (last_gui_progress != 0 || gui_progress != 100)) {
|
||||||
last_gui_progress = gui_progress;
|
last_gui_progress = gui_progress;
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_PROGRESS);
|
if (wxApp::GetInstance() != nullptr) {
|
||||||
evt->SetString(GUI::from_u8(std::to_string(gui_progress)));
|
wxCommandEvent *evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_PROGRESS);
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
evt->SetString(GUI::from_u8(std::to_string(gui_progress)));
|
||||||
}
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// on_complete
|
// on_complete
|
||||||
@ -293,19 +301,24 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d
|
|||||||
{
|
{
|
||||||
if (m_cancel) {
|
if (m_cancel) {
|
||||||
BOOST_LOG_TRIVIAL(info) << error_message;
|
BOOST_LOG_TRIVIAL(info) << error_message;
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED); // FAILED with empty msg only closes progress notification
|
if (wxApp::GetInstance() != nullptr) {
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
wxCommandEvent *evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED
|
||||||
} else {
|
); // FAILED with empty msg only closes progress notification
|
||||||
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
std::string message = (error_message.empty()
|
std::string message = (error_message.empty()
|
||||||
? std::string()
|
? std::string()
|
||||||
: GUI::format(_u8L("Downloading new %1% has failed:\n%2%"), SLIC3R_APP_NAME, error_message));
|
: GUI::format(_u8L("Downloading new %1% has failed:\n%2%"), SLIC3R_APP_NAME, error_message));
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
|
if (wxApp::GetInstance() != nullptr) {
|
||||||
if (!message.empty()) {
|
wxCommandEvent *evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
|
||||||
BOOST_LOG_TRIVIAL(error) << message;
|
if (!message.empty()) {
|
||||||
evt->SetString(message);
|
BOOST_LOG_TRIVIAL(error) << message;
|
||||||
}
|
evt->SetString(message);
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
}
|
||||||
}
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
|
}
|
||||||
|
}
|
||||||
return boost::filesystem::path();
|
return boost::filesystem::path();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +349,7 @@ void AppUpdater::priv::version_check(const std::string& version_check_url)
|
|||||||
if (!res) {
|
if (!res) {
|
||||||
std::string message = GUI::format("Downloading %1% version file has failed:\n%2%", SLIC3R_APP_NAME, error_message);
|
std::string message = GUI::format("Downloading %1% version file has failed:\n%2%", SLIC3R_APP_NAME, error_message);
|
||||||
BOOST_LOG_TRIVIAL(error) << message;
|
BOOST_LOG_TRIVIAL(error) << message;
|
||||||
if (m_triggered_by_user) {
|
if (m_triggered_by_user && wxApp::GetInstance() != nullptr) {
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
|
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
|
||||||
evt->SetString(message);
|
evt->SetString(message);
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
@ -356,10 +369,12 @@ void AppUpdater::priv::parse_version_string(const std::string& body)
|
|||||||
BOOST_LOG_TRIVIAL(error) << "Could not find property tree in version file. Checking for application update has failed.";
|
BOOST_LOG_TRIVIAL(error) << "Could not find property tree in version file. Checking for application update has failed.";
|
||||||
// Lets send event with current version, this way if user triggered this check, it will notify him about no new version online.
|
// Lets send event with current version, this way if user triggered this check, it will notify him about no new version online.
|
||||||
std::string version = Semver().to_string();
|
std::string version = Semver().to_string();
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
|
if (wxApp::GetInstance() != nullptr) {
|
||||||
evt->SetString(GUI::from_u8(version));
|
wxCommandEvent *evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
evt->SetString(GUI::from_u8(version));
|
||||||
return;
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
std::string tree_string = body.substr(start);
|
std::string tree_string = body.substr(start);
|
||||||
boost::property_tree::ptree tree;
|
boost::property_tree::ptree tree;
|
||||||
@ -444,7 +459,7 @@ void AppUpdater::priv::parse_version_string(const std::string& body)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// send prerelease version to UI layer
|
// send prerelease version to UI layer
|
||||||
if (recent_version) {
|
if (recent_version && wxApp::GetInstance() != nullptr) {
|
||||||
BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME, version_string);
|
BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME, version_string);
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_EXPERIMENTAL_VERSION_ONLINE);
|
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_EXPERIMENTAL_VERSION_ONLINE);
|
||||||
evt->SetString(GUI::from_u8(version_string));
|
evt->SetString(GUI::from_u8(version_string));
|
||||||
@ -459,9 +474,11 @@ void AppUpdater::priv::parse_version_string(const std::string& body)
|
|||||||
// send
|
// send
|
||||||
std::string version = new_data.version.get().to_string();
|
std::string version = new_data.version.get().to_string();
|
||||||
BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME, version);
|
BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME, version);
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
|
if (wxApp::GetInstance() != nullptr) {
|
||||||
evt->SetString(GUI::from_u8(version));
|
wxCommandEvent *evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
evt->SetString(GUI::from_u8(version));
|
||||||
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 //lm:is this meant to be ressurected? //dk: it is code that parses PrusaSlicer.version2 in 2.4.0, It was deleted from PresetUpdater.cpp and I would keep it here for possible reference.
|
#if 0 //lm:is this meant to be ressurected? //dk: it is code that parses PrusaSlicer.version2 in 2.4.0, It was deleted from PresetUpdater.cpp and I would keep it here for possible reference.
|
||||||
@ -481,9 +498,11 @@ void AppUpdater::priv::parse_version_string_old(const std::string& body) const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME, version);
|
BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME, version);
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
|
if (wxApp::GetInstance() != nullptr) {
|
||||||
evt->SetString(GUI::from_u8(version));
|
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
evt->SetString(GUI::from_u8(version));
|
||||||
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
|
}
|
||||||
|
|
||||||
// alpha / beta version
|
// alpha / beta version
|
||||||
std::vector<std::string> prerelease_versions;
|
std::vector<std::string> prerelease_versions;
|
||||||
@ -525,7 +544,7 @@ void AppUpdater::priv::parse_version_string_old(const std::string& body) const
|
|||||||
version = ver_string;
|
version = ver_string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (recent_version) {
|
if (recent_version && wxApp::GetInstance() != nullptr) {
|
||||||
BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME, version);
|
BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME, version);
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_EXPERIMENTAL_VERSION_ONLINE);
|
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_EXPERIMENTAL_VERSION_ONLINE);
|
||||||
evt->SetString(GUI::from_u8(version));
|
evt->SetString(GUI::from_u8(version));
|
||||||
|
@ -1186,6 +1186,11 @@ PresetUpdater::UpdateResult PresetUpdater::config_update(const Semver& old_slic3
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!wxApp::GetInstance() || ! GUI::wxGetApp().plater()) {
|
||||||
|
// The main thread might have start killing the UI.
|
||||||
|
return R_NOOP;
|
||||||
|
}
|
||||||
|
|
||||||
// regular update
|
// regular update
|
||||||
if (params == UpdateParams::SHOW_NOTIFICATION) {
|
if (params == UpdateParams::SHOW_NOTIFICATION) {
|
||||||
p->set_waiting_updates(updates);
|
p->set_waiting_updates(updates);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user