| 328 | } |
| 329 | |
| 330 | bool TaskManager::update_progress_bg(bool p_force_refresh, bool called_from_process, bool *r_did_redraw) { |
| 331 | if (updating_bg || (group_id_to_description.empty() && !Thread::is_main_thread())) { |
| 332 | if (r_did_redraw) { |
| 333 | *r_did_redraw = false; |
| 334 | } |
| 335 | return false; |
| 336 | } |
| 337 | updating_bg = true; |
| 338 | bool main_loop_iterating = false; |
| 339 | bool canceled = false; |
| 340 | Vector<TaskManagerID> task_ids_to_erase; |
| 341 | group_id_to_description.for_each_m([&](auto &v) { |
| 342 | if (v.second->_is_aborted()) { |
| 343 | if (v.second->is_done()) { |
| 344 | task_ids_to_erase.push_back(v.first); |
| 345 | } |
| 346 | } else { |
| 347 | if (v.second->is_progress_enabled() && v.second->is_started()) { |
| 348 | main_loop_iterating = true; |
| 349 | v.second->update_progress(false); |
| 350 | } |
| 351 | if (v.second->is_canceled()) { |
| 352 | canceled = true; |
| 353 | } |
| 354 | } |
| 355 | }); |
| 356 | for (auto &task_id : task_ids_to_erase) { |
| 357 | group_id_to_description.erase(task_id); |
| 358 | } |
| 359 | if (p_force_refresh && main_loop_iterating && GDREProgressDialog::is_safe_to_redraw() && GDREProgressDialog::get_singleton()) { |
| 360 | bool did_redraw = GDREProgressDialog::get_singleton()->main_thread_update(); |
| 361 | if (r_did_redraw) { |
| 362 | *r_did_redraw = did_redraw; |
| 363 | } |
| 364 | } |
| 365 | // TODO: remove this, move it into main loop |
| 366 | // this should only be called if this wasn't called from `GodotREEditorStandalone::process()` and there are tasks in the queue and none of them have progress enabled |
| 367 | if (!called_from_process && !main_loop_iterating && Thread::is_main_thread() && !MessageQueue::get_singleton()->is_flushing() && group_id_to_description.size() > 0) { |
| 368 | GDRESettings::main_iteration(); |
| 369 | if (r_did_redraw) { |
| 370 | *r_did_redraw = true; |
| 371 | } |
| 372 | } |
| 373 | updating_bg = false; |
| 374 | return canceled; |
| 375 | } |
| 376 | |
| 377 | void TaskManager::set_thread_task_id(TaskManagerID p_task_manager_id) { |
| 378 | if (Thread::is_main_thread()) { |
no test coverage detected