Crash running QProcess from a test class

Crash running QProcess from a test class

Anonymous
Not applicable
485 Views
0 Replies
Message 1 of 1

Crash running QProcess from a test class

Anonymous
Not applicable

I'm trying to start a QProcess from another class in Maya and the code is causing Maya to crash. It crashes specifically when I'm connecting the started and finished signals in the class. Does anyone have any clue as to why this would be happening? 

from PySide2 import QtCore
from PySide2 import QtGui
from PySide2 import QtWidgets
from PySide2.QtCore import QObject, Signal, Slot
import maya.cmds as mc
class SubProcess(QObject):
    outputChangedSignal = Signal(str)
    finishedSignal = Signal(str)
    def __init__(self, command = "", path=None, args=None):
        super(SubProcess, self).__init__()
        self.command = command
        self.process = QtCore.QProcess()
    def started(self):
        print "Started!"
    def finished(self):
        print("Finished!")
        self.finishedSignal.emit("Finished")
    @Anonymous()
    def readStdOutput(self):
        output = str(self.process.readAllStandardOutput())
        self.outputChangedSignal.emit(output)
    def executeCommand(self):
        self.process.started.connect(self.started)
        self.process.setProcessChannelMode(QtCore.QProcess.MergedChannels)
        self.process.readyReadStandardOutput.connect(self.readStdOutput)
        self.process.finished.connect(self.finished)
        try:
            self.process.start(self.command)
        except Exception, e:
            print("ERROR: " + e)
class Test():
    def __init__(self):
        testCommand = "sh -c echo hello"
        print('>>> {0}'.format(testCommand))
        proc = SubProcess(command=testCommand)
        proc.executeCommand()
'''
This crashes Maya
'''       
testDialog = Test()
'''
This works fine
'''
'''
testCommand = "sh -c echo hello"
print('>>> {0}'.format(testCommand))
proc = SubProcess(command=testCommand)
proc.executeCommand()
'''
0 Likes
486 Views
0 Replies
Replies (0)