Skip to content
Permalink
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 25, 2019
1 parent 67f5022 commit b82ce0e5227f5c24aaf66229cae8e671b2bb533a
Showing with 10 additions and 2 deletions.
  1. +10 −2 python/console/console_output.py
@@ -19,7 +19,7 @@
Some portions of code were taken from https://code.google.com/p/pydee/
"""

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
"""
super().__init__()
self.sO = shellOut
self.out = None
self.style = style
self.fire_keyboard_interrupt = False

@pyqtSlot(str)
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))
return

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

0 comments on commit b82ce0e

Please sign in to comment.
You can’t perform that action at this time.