Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 091776d

Browse files
committed
Merge pull request #1905 from jschueller/master
Prevent Qt4 from stopping the interpreter
2 parents 3ab0ba0 + 48e5bb1 commit 091776d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/matplotlib/backends/backend_qt4.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import division, print_function
22
import math
33
import os
4+
import re
45
import signal
56
import sys
67

@@ -53,6 +54,13 @@ def _create_qApp():
5354
global qApp
5455
app = QtGui.QApplication.instance()
5556
if app is None:
57+
58+
# check for DISPLAY env variable on X11 build of Qt
59+
if hasattr(QtGui, "QX11Info"):
60+
display = os.environ.get('DISPLAY')
61+
if display is None or not re.search(':\d', display):
62+
raise RuntimeError('Invalid DISPLAY variable')
63+
5664
qApp = QtGui.QApplication( [" "] )
5765
QtCore.QObject.connect( qApp, QtCore.SIGNAL( "lastWindowClosed()" ),
5866
qApp, QtCore.SLOT( "quit()" ) )

0 commit comments

Comments
 (0)