Skip to content

Commit 7e7aa83

Browse files
committed
fix preview with updated progress bars
1 parent 16a281e commit 7e7aa83

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/server/main.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,11 +1170,13 @@ void step_callback(int step, sd_image_t image) {
11701170
stbi_write_png(preview_path, image.width, image.height, image.channel, image.data, 0);
11711171
}
11721172

1173-
json task_json = json::object();
1173+
json task_json = task_results[running_task_id];
1174+
if (task_json == NULL) {
1175+
// shouldn't happen
1176+
task_json = json::object();
1177+
}
11741178
task_json["status"] = "Working";
11751179
task_json["data"] = json::array();
1176-
task_json["step"] = step;
1177-
task_json["eta"] = "?";
11781180

11791181
int len;
11801182
unsigned char* png = stbi_write_png_to_mem((const unsigned char*)image.data, 0, image.width, image.height, image.channel, &len, NULL);
@@ -1413,7 +1415,7 @@ void start_server(SDParams params) {
14131415
end_task_json["status"] = "Done";
14141416
end_task_json["data"] = images_json;
14151417
end_task_json["step"] = -1;
1416-
end_task_json["steps"] = 0;
1418+
end_task_json["steps"] = 0;
14171419
end_task_json["eta"] = "?";
14181420
std::lock_guard<std::mutex> results_lock(results_mutex);
14191421
task_results[task_id] = end_task_json;

0 commit comments

Comments
 (0)