mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-09 00:08:52 -04:00
Fix excepthook handling in standalone scripts
This commit is contained in:
parent
34a8c8aab8
commit
acbba3a387
@ -30,7 +30,7 @@ QGIS utilities module
|
|||||||
|
|
||||||
from qgis.PyQt.QtCore import QCoreApplication, QLocale, QThread
|
from qgis.PyQt.QtCore import QCoreApplication, QLocale, QThread
|
||||||
from qgis.PyQt.QtWidgets import QPushButton, QApplication
|
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
|
from qgis.gui import QgsMessageBar
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@ -133,7 +133,7 @@ def show_message_log(pop_error=True):
|
|||||||
|
|
||||||
|
|
||||||
def open_stack_dialog(type, value, tb, msg, 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()
|
iface.messageBar().popWidget()
|
||||||
|
|
||||||
if msg is None:
|
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):
|
def qgis_excepthook(type, value, tb):
|
||||||
# detect if running in the main thread
|
# 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!
|
# only use messagebar if running in main thread - otherwise it will crash!
|
||||||
showException(type, value, tb, None, messagebar=in_main_thread)
|
showException(type, value, tb, None, messagebar=in_main_thread)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user