|
30 | 30 |
|
31 | 31 | from qgis.PyQt.QtCore import QCoreApplication, QLocale, QThread
|
32 | 32 | from qgis.PyQt.QtWidgets import QPushButton, QApplication
|
33 |
| -from qgis.core import Qgis, QgsExpression, QgsMessageLog, qgsfunction, QgsMessageOutput, QgsWkbTypes, QgsApplication |
| 33 | +from qgis.core import Qgis, QgsExpression, QgsMessageLog, qgsfunction, QgsMessageOutput, QgsWkbTypes |
34 | 34 | from qgis.gui import QgsMessageBar
|
35 | 35 |
|
36 | 36 | import sys
|
@@ -133,7 +133,7 @@ def show_message_log(pop_error=True):
|
133 | 133 |
|
134 | 134 |
|
135 | 135 | def open_stack_dialog(type, value, tb, msg, pop_error=True):
|
136 |
| - if pop_error: |
| 136 | + if pop_error and iface is not None: |
137 | 137 | iface.messageBar().popWidget()
|
138 | 138 |
|
139 | 139 | if msg is None:
|
@@ -189,7 +189,7 @@ def open_stack_dialog(type, value, tb, msg, pop_error=True):
|
189 | 189 |
|
190 | 190 | def qgis_excepthook(type, value, tb):
|
191 | 191 | # detect if running in the main thread
|
192 |
| - in_main_thread = QThread.currentThread() == QgsApplication.instance().thread() |
| 192 | + in_main_thread = QCoreApplication.instance() is None or QThread.currentThread() == QCoreApplication.instance().thread() |
193 | 193 |
|
194 | 194 | # only use messagebar if running in main thread - otherwise it will crash!
|
195 | 195 | showException(type, value, tb, None, messagebar=in_main_thread)
|
|
0 commit comments