Skip to content

Commit

Permalink
Fix excepthook handling in standalone scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 23, 2017
1 parent 34a8c8a commit acbba3a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python/utils.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit acbba3a

Please sign in to comment.