Skip to content

Commit eb34079

Browse files
committed
Don't crash when python exceptions occur in non-main thread
1 parent 4c0f4ee commit eb34079

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

python/utils.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,13 @@ def open_stack_dialog(type, value, tb, msg, pop_error=True):
193193

194194

195195
def qgis_excepthook(type, value, tb):
196-
showException(type, value, tb, None, messagebar=True)
196+
# detect if running in the main thread
197+
in_main_thread = True
198+
if QThread.currentThread() != QgsApplication.instance().thread():
199+
in_main_thread = False
200+
201+
# only use messagebar if running in main thread - otherwise it will crash!
202+
showException(type, value, tb, None, messagebar=in_main_thread)
197203

198204

199205
def installErrorHook():

0 commit comments

Comments
 (0)