diff --git a/src/libslic3r/ProjectTask.hpp b/src/libslic3r/ProjectTask.hpp index 692060c91b..a86a24cf47 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 967d8d5016..972c02a87f 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -2695,6 +2695,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(); @@ -2703,11 +2708,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 00fc2e0610..7d7bf69cf7 100644 --- a/src/slic3r/GUI/StatusPanel.hpp +++ b/src/slic3r/GUI/StatusPanel.hpp @@ -75,6 +75,8 @@ struct ScoreData std::vector> 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 e7bcebeec1..2d3799642d 100644 --- a/src/slic3r/Utils/NetworkAgent.cpp +++ b/src/slic3r/Utils/NetworkAgent.cpp @@ -1183,11 +1183,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 98a4644a82..27525227c3 100644 --- a/src/slic3r/Utils/NetworkAgent.hpp +++ b/src/slic3r/Utils/NetworkAgent.hpp @@ -78,7 +78,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); @@ -179,7 +179,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);