From 44eaa75110cb324bdc7c35a06247d45ea4244882 Mon Sep 17 00:00:00 2001 From: tao wang Date: Wed, 23 Aug 2023 20:41:07 +0800 Subject: [PATCH] FIX:fixed studio crash caused by HTTP request blocking jira:[STUDIO-3849] Change-Id: I6348af96014e80da6b720da48239fed262f0f3c5 --- src/libslic3r/ProjectTask.hpp | 2 ++ src/slic3r/GUI/StatusPanel.cpp | 11 ++++++----- src/slic3r/GUI/StatusPanel.hpp | 2 ++ src/slic3r/Utils/NetworkAgent.cpp | 4 ++-- src/slic3r/Utils/NetworkAgent.hpp | 4 ++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/libslic3r/ProjectTask.hpp b/src/libslic3r/ProjectTask.hpp index 692060c91..a86a24cf4 100644 --- a/src/libslic3r/ProjectTask.hpp +++ b/src/libslic3r/ProjectTask.hpp @@ -192,6 +192,8 @@ public: static BBLSubTask::SubTaskStatus parse_user_service_task_status(int status); }; +typedef std::function OnGetSubTaskFn; + class BBLTask { public: enum TaskStatus { diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index 730b8af1c..00bcae992 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -2621,6 +2621,11 @@ void StatusPanel::update_basic_print_data(bool def) void StatusPanel::update_model_info() { + auto get_subtask_fn = [this](BBLModelTask* subtask) { + obj->set_modeltask(subtask); + }; + + if (wxGetApp().getAgent() && obj) { BBLSubTask* curr_task = obj->get_subtask(); @@ -2629,11 +2634,7 @@ void StatusPanel::update_model_info() if (!curr_model_task) { curr_model_task = new BBLModelTask(); curr_model_task->task_id = curr_task->task_id; - int result = wxGetApp().getAgent()->get_subtask(curr_model_task); - - if (result > -1) { - obj->set_modeltask(curr_model_task); - } + wxGetApp().getAgent()->get_subtask(curr_model_task, get_subtask_fn); } } } diff --git a/src/slic3r/GUI/StatusPanel.hpp b/src/slic3r/GUI/StatusPanel.hpp index c0bc145e1..9ef3f6b2d 100644 --- a/src/slic3r/GUI/StatusPanel.hpp +++ b/src/slic3r/GUI/StatusPanel.hpp @@ -74,6 +74,8 @@ struct ScoreData std::unordered_map local_to_url_image; }; +typedef std::function OnGetSubTaskFn; + class ScoreDialog : public GUI::DPIDialog { public: diff --git a/src/slic3r/Utils/NetworkAgent.cpp b/src/slic3r/Utils/NetworkAgent.cpp index b21a6aedc..5ecedad8c 100644 --- a/src/slic3r/Utils/NetworkAgent.cpp +++ b/src/slic3r/Utils/NetworkAgent.cpp @@ -1194,11 +1194,11 @@ int NetworkAgent::get_model_publish_url(std::string* url) return ret; } -int NetworkAgent::get_subtask(BBLModelTask* task) +int NetworkAgent::get_subtask(BBLModelTask* task, OnGetSubTaskFn getsub_fn) { int ret = 0; if (network_agent && get_subtask_ptr) { - ret = get_subtask_ptr(network_agent, task); + ret = get_subtask_ptr(network_agent, task, getsub_fn); if (ret) BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") % network_agent % ret; } diff --git a/src/slic3r/Utils/NetworkAgent.hpp b/src/slic3r/Utils/NetworkAgent.hpp index 38d14583d..7268ee07f 100644 --- a/src/slic3r/Utils/NetworkAgent.hpp +++ b/src/slic3r/Utils/NetworkAgent.hpp @@ -79,7 +79,7 @@ typedef int (*func_get_design_staffpick)(void *agent, int offset, int limit, std typedef int (*func_start_pubilsh)(void *agent, PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string* out); typedef int (*func_get_profile_3mf)(void *agent, BBLProfile* profile); typedef int (*func_get_model_publish_url)(void *agent, std::string* url); -typedef int (*func_get_subtask)(void *agent, BBLModelTask* task); +typedef int (*func_get_subtask)(void *agent, BBLModelTask* task, OnGetSubTaskFn getsub_fn); typedef int (*func_get_model_mall_home_url)(void *agent, std::string* url); typedef int (*func_get_model_mall_detail_url)(void *agent, std::string* url, std::string id); typedef int (*func_get_my_profile)(void *agent, std::string token, unsigned int *http_code, std::string *http_body); @@ -180,7 +180,7 @@ public: int start_publish(PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string* out); int get_profile_3mf(BBLProfile* profile); int get_model_publish_url(std::string* url); - int get_subtask(BBLModelTask* task); + int get_subtask(BBLModelTask* task, OnGetSubTaskFn getsub_fn); int get_model_mall_home_url(std::string* url); int get_model_mall_detail_url(std::string* url, std::string id); int get_my_profile(std::string token, unsigned int* http_code, std::string* http_body);