From fcfe98c8eda9d44bcc856539ad02715583c64acf Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 9 Jun 2023 12:06:09 +1000 Subject: [PATCH] Some super-safety in overridden stdout/stderr to ensure we don't try to write to a deleted qwidget --- python/console/console_output.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/console/console_output.py b/python/console/console_output.py index 060dbc892f6..cd5c3b513c2 100644 --- a/python/console/console_output.py +++ b/python/console/console_output.py @@ -19,6 +19,7 @@ email : lrssvtml (at) gmail (dot) com Some portions of code were taken from https://code.google.com/p/pydee/ """ +from qgis.PyQt import sip from qgis.PyQt.QtCore import Qt, QCoreApplication, QThread, QMetaObject, Q_ARG, QObject, pyqtSlot from qgis.PyQt.QtGui import QColor, QKeySequence from qgis.PyQt.QtWidgets import QGridLayout, QSpacerItem, QSizePolicy, QShortcut, QMenu, QApplication @@ -43,6 +44,8 @@ class writeOut(QObject): @pyqtSlot(str) def write(self, m): + if sip.isdeleted(self.sO): + return # This manage the case when console is called from another thread if QThread.currentThread() != QCoreApplication.instance().thread():