From 21099e30cb666d65b53fbcd749793ce6f5fe6776 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 15 Feb 2019 12:51:40 +0100 Subject: [PATCH] Check if on main thread for call_on_qt_thread CURA-6225 --- cura/Utils/Threading.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cura/Utils/Threading.py b/cura/Utils/Threading.py index 3cd6200513..c57a452b72 100644 --- a/cura/Utils/Threading.py +++ b/cura/Utils/Threading.py @@ -31,4 +31,10 @@ def call_on_qt_thread(func): CuraApplication.getInstance().callLater(_handle_call, *new_args, **kwargs) inter_call_object.finish_event.wait() return inter_call_object.result + + # If the current thread is the main thread, which is the Qt thread, directly return the function. + current_thread = threading.current_thread() + if isinstance(current_thread, threading._MainThread): + return func + return _call_on_qt_thread_wrapper