Don't crash when python exceptions occur in non-main thread

This commit is contained in:
Nyall Dawson 2016-04-22 07:35:12 +10:00
parent 4c0f4ee6f0
commit eb34079c01

View File

@ -193,7 +193,13 @@ def open_stack_dialog(type, value, tb, msg, pop_error=True):
def qgis_excepthook(type, value, tb):
showException(type, value, tb, None, messagebar=True)
# detect if running in the main thread
in_main_thread = True
if QThread.currentThread() != QgsApplication.instance().thread():
in_main_thread = False
# only use messagebar if running in main thread - otherwise it will crash!
showException(type, value, tb, None, messagebar=in_main_thread)
def installErrorHook():