diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-06-17 16:01:58 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-06-17 16:01:58 +0200 |
commit | cf50779ef80c6158f2af72bbcc250731151c7c0f (patch) | |
tree | 576d751473e8fd30e8a54969a4ff24a40cd9fe05 | |
parent | 0a543a608504bad44296a5f1936fcbc76af38010 (diff) | |
parent | 7acaa0d3206ee2863bd81acd0bb0aa77b66c687d (diff) | |
download | redot-engine-cf50779ef80c6158f2af72bbcc250731151c7c0f.tar.gz |
Merge pull request #93160 from bruvzg/pg_mt_crash
[EditorProgress] Use `BackgroundProgress` instead of `ProgressDialog` when called for a thread.
-rw-r--r-- | editor/editor_node.h | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/editor/editor_node.h b/editor/editor_node.h index 899da99450..2127d30765 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -928,12 +928,29 @@ public: struct EditorProgress { String task; - bool step(const String &p_state, int p_step = -1, bool p_force_refresh = true) { return EditorNode::progress_task_step(task, p_state, p_step, p_force_refresh); } + bool step(const String &p_state, int p_step = -1, bool p_force_refresh = true) { + if (Thread::is_main_thread()) { + return EditorNode::progress_task_step(task, p_state, p_step, p_force_refresh); + } else { + EditorNode::progress_task_step_bg(task, p_step); + return false; + } + } EditorProgress(const String &p_task, const String &p_label, int p_amount, bool p_can_cancel = false) { - EditorNode::progress_add_task(p_task, p_label, p_amount, p_can_cancel); + if (Thread::is_main_thread()) { + EditorNode::progress_add_task(p_task, p_label, p_amount, p_can_cancel); + } else { + EditorNode::progress_add_task_bg(p_task, p_label, p_amount); + } task = p_task; } - ~EditorProgress() { EditorNode::progress_end_task(task); } + ~EditorProgress() { + if (Thread::is_main_thread()) { + EditorNode::progress_end_task(task); + } else { + EditorNode::progress_end_task_bg(task); + } + } }; class EditorPluginList : public Object { |