Skip to content
Browse files
fix crash when print from qgis processing algorithm while the python …
…console is displayed
  • Loading branch information
troopa81 authored and nyalldawson committed Jan 29, 2019
1 parent e9ae431 commit 5f38b34599b2f4b40407b94a57ee91b11bd77b93
Showing with 10 additions and 2 deletions.
  1. +10 −2 python/console/
@@ -19,7 +19,7 @@
Some portions of code were taken from

from qgis.PyQt.QtCore import Qt, QCoreApplication
from qgis.PyQt.QtCore import Qt, QCoreApplication, QThread, QMetaObject, Q_RETURN_ARG, Q_ARG, QObject, pyqtSlot
from qgis.PyQt.QtGui import QColor, QFont, QKeySequence, QFontDatabase
from qgis.PyQt.QtWidgets import QGridLayout, QSpacerItem, QSizePolicy, QShortcut, QMenu, QApplication
from qgis.PyQt.Qsci import QsciScintilla, QsciLexerPython
@@ -28,20 +28,28 @@
import sys

class writeOut(object):
class writeOut(QObject):

ERROR_COLOR = "#e31a1c"

def __init__(self, shellOut, out=None, style=None):
This class allows writing to stdout and stderr
self.sO = shellOut
self.out = None = style
self.fire_keyboard_interrupt = False

def write(self, m):

# This manage the case when console is called from another thread
if QThread.currentThread() != QCoreApplication.instance().thread():
QMetaObject.invokeMethod(self, "write", Qt.QueuedConnection, Q_ARG(str, m))

if == "_traceback":
# Show errors in red
stderrColor = QColor(self.sO.settings.value("pythonConsole/stderrFontColor", QColor(self.ERROR_COLOR)))

0 comments on commit 5f38b34

Please sign in to comment.