Debugger: Delay matplot process initialization

Reduces costs in case the feature is not requested.

Change-Id: I66da6f256baaec6ef9d40bc135942551d58e83da
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-01-28 17:04:42 +01:00
parent 401d66764c
commit c5c229b48f

View File

@@ -91,24 +91,33 @@ except:
if hasSubprocess and hasPlot:
matplotFigure = {}
matplotCount = 0
matplotProc = None
devNull = None
devNull = open(os.devnull)
# FIXME: That might not be the one we want.
pythonExecutable = sys.executable
matplotProc = subprocess.Popen(args=[pythonExecutable, "-i"],
bufsize=0, stdin=subprocess.PIPE, stdout=devNull, stderr=devNull)
def matplotInit():
global matplotProc
global devNull
matplotProc.stdin.write(b"import sys\n")
matplotProc.stdin.write(b"sys.ps1=''\n")
matplotProc.stdin.write(b"from matplotlib import pyplot\n")
matplotProc.stdin.write(b"import time\n")
matplotProc.stdin.write(b"pyplot.ion()\n")
matplotProc.stdin.flush()
if matplotProc is None:
devNull = open(os.devnull)
# FIXME: That might not be the one we want.
pythonExecutable = sys.executable
matplotProc = subprocess.Popen(args=[pythonExecutable, "-i"],
bufsize=0, stdin=subprocess.PIPE, stdout=devNull, stderr=devNull)
matplotProc.stdin.write(b"import sys\n")
matplotProc.stdin.write(b"sys.ps1=''\n")
matplotProc.stdin.write(b"from matplotlib import pyplot\n")
matplotProc.stdin.write(b"import time\n")
matplotProc.stdin.write(b"pyplot.ion()\n")
matplotProc.stdin.flush()
def matplotSend(iname, show, data):
global matplotFigure
global matplotCount
matplotInit()
def s(line):
matplotProc.stdin.write(line.encode("latin1"))
matplotProc.stdin.write(b"\n")
@@ -136,9 +145,11 @@ if hasSubprocess and hasPlot:
matplotProc.stdin.flush()
def matplotQuit():
matplotProc.stdin.write(b"exit")
matplotProc.kill()
devNull.close()
global matplotProc
if not matplotProc is None:
matplotProc.stdin.write(b"exit")
matplotProc.kill()
devNull.close()
def arrayForms():
global hasPlot