Skip to content

Commit

Permalink
Merge pull request #1905 from jschueller/master
Browse files Browse the repository at this point in the history
Prevent Qt4 from stopping the interpreter
  • Loading branch information
mdboom committed Apr 19, 2013
2 parents 3ab0ba0 + 48e5bb1 commit 091776d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/matplotlib/backends/backend_qt4.py
@@ -1,6 +1,7 @@
from __future__ import division, print_function
import math
import os
import re
import signal
import sys

Expand Down Expand Up @@ -53,6 +54,13 @@ def _create_qApp():
global qApp
app = QtGui.QApplication.instance()
if app is None:

# check for DISPLAY env variable on X11 build of Qt
if hasattr(QtGui, "QX11Info"):
display = os.environ.get('DISPLAY')
if display is None or not re.search(':\d', display):
raise RuntimeError('Invalid DISPLAY variable')

qApp = QtGui.QApplication( [" "] )
QtCore.QObject.connect( qApp, QtCore.SIGNAL( "lastWindowClosed()" ),
qApp, QtCore.SLOT( "quit()" ) )
Expand Down

0 comments on commit 091776d

Please sign in to comment.