Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

inputhookqt4: make hook more robust in case of unexpected conditions

 - return early if there's no longer a qApp
 - trap any exception that could be raised from within the hook,
   report it and unregister the hook
  • Loading branch information...
commit da13a62776925f10a106e58ff8bd1a8a39faccac 1 parent be8bbf1
@cboos authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 IPython/lib/inputhookqt4.py
View
7 IPython/lib/inputhookqt4.py
@@ -81,6 +81,8 @@ def inputhook_qt4():
try:
allow_CTRL_C()
app = QtCore.QCoreApplication.instance()
+ if not app: # shouldn't happen, but safer if it happens anyway...
+ return 0
app.processEvents(QtCore.QEventLoop.AllEvents, 300)
if not stdin_ready():
timer = QtCore.QTimer()
@@ -99,6 +101,11 @@ def inputhook_qt4():
" permanently"
"\n and '%gui qt4' to re-enable it later")
mgr.clear_inputhook()
+ except: # NO exceptions are allowed to escape from a ctypes callback
+ mgr.clear_inputhook()
+ from traceback import print_exc
+ print_exc()
+ print("Got exception from inputhook_qt4, unregistering.")
return 0
def preprompthook_qt4(ishell):
Please sign in to comment.
Something went wrong with that request. Please try again.