mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-06 22:47:32 -06:00
FIX:add protection if task information is empty
jira:[for new] Change-Id: Icfdf254eca23022ea3f861168d3894ef866fe792
This commit is contained in:
parent
b484fb1406
commit
1ed54b1d5d
1 changed files with 17 additions and 13 deletions
|
@ -4662,22 +4662,26 @@ void MachineObject::update_slice_info(std::string project_id, std::string profil
|
|||
std::string http_body;
|
||||
if (m_agent->get_subtask_info(subtask_id, &subtask_json, &http_code, &http_body) == 0) {
|
||||
try {
|
||||
json task_j = json::parse(subtask_json);
|
||||
if (task_j.contains("content")) {
|
||||
std::string content_str = task_j["content"].get<std::string>();
|
||||
json content_j = json::parse(content_str);
|
||||
plate_index = content_j["info"]["plate_idx"].get<int>();
|
||||
}
|
||||
if (!subtask_json.empty()){
|
||||
|
||||
if (task_j.contains("context") && task_j["context"].contains("plates")) {
|
||||
for (int i = 0; i < task_j["context"]["plates"].size(); i++) {
|
||||
if (task_j["context"]["plates"][i].contains("index") && task_j["context"]["plates"][i]["index"].get<int>() == plate_index) {
|
||||
slice_info->thumbnail_url = task_j["context"]["plates"][i]["thumbnail"]["url"].get<std::string>();
|
||||
BOOST_LOG_TRIVIAL(trace) << "task_info: thumbnail url=" << slice_info->thumbnail_url;
|
||||
json task_j = json::parse(subtask_json);
|
||||
if (task_j.contains("content")) {
|
||||
std::string content_str = task_j["content"].get<std::string>();
|
||||
json content_j = json::parse(content_str);
|
||||
plate_index = content_j["info"]["plate_idx"].get<int>();
|
||||
}
|
||||
|
||||
if (task_j.contains("context") && task_j["context"].contains("plates")) {
|
||||
for (int i = 0; i < task_j["context"]["plates"].size(); i++) {
|
||||
if (task_j["context"]["plates"][i].contains("index") && task_j["context"]["plates"][i]["index"].get<int>() == plate_index) {
|
||||
slice_info->thumbnail_url = task_j["context"]["plates"][i]["thumbnail"]["url"].get<std::string>();
|
||||
BOOST_LOG_TRIVIAL(trace) << "task_info: thumbnail url=" << slice_info->thumbnail_url;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "task_info: no context or plates";
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(error) << "task_info: no context or plates";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(...) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue