Skip to content
Permalink
Browse files

Fix excepthook handling in standalone scripts

  • Loading branch information
nyalldawson committed Sep 23, 2017
1 parent 34a8c8a commit acbba3a387797a2b64ae3f857bd2648e3ddcdfd1
Showing with 3 additions and 3 deletions.
  1. +3 −3 python/utils.py
@@ -30,7 +30,7 @@

from qgis.PyQt.QtCore import QCoreApplication, QLocale, QThread
from qgis.PyQt.QtWidgets import QPushButton, QApplication
from qgis.core import Qgis, QgsExpression, QgsMessageLog, qgsfunction, QgsMessageOutput, QgsWkbTypes, QgsApplication
from qgis.core import Qgis, QgsExpression, QgsMessageLog, qgsfunction, QgsMessageOutput, QgsWkbTypes
from qgis.gui import QgsMessageBar

import sys
@@ -133,7 +133,7 @@ def show_message_log(pop_error=True):


def open_stack_dialog(type, value, tb, msg, pop_error=True):
if pop_error:
if pop_error and iface is not None:
iface.messageBar().popWidget()

if msg is None:
@@ -189,7 +189,7 @@ def open_stack_dialog(type, value, tb, msg, pop_error=True):

def qgis_excepthook(type, value, tb):
# detect if running in the main thread
in_main_thread = QThread.currentThread() == QgsApplication.instance().thread()
in_main_thread = QCoreApplication.instance() is None or QThread.currentThread() == QCoreApplication.instance().thread()

# only use messagebar if running in main thread - otherwise it will crash!
showException(type, value, tb, None, messagebar=in_main_thread)

0 comments on commit acbba3a

Please sign in to comment.
You can’t perform that action at this time.