diff --git a/canvas/Canvas.py b/canvas/Canvas.py
index 95293515..659480fd 100644
--- a/canvas/Canvas.py
+++ b/canvas/Canvas.py
@@ -519,6 +519,10 @@ class Canvas(QtGui.QWidget):
## disconnect signals, remove from list, etc..
+ def clear(self):
+ while len(self.items) > 0:
+ self.removeItem(self.items[0])
+
def addToScene(self, item):
self.view.addItem(item)
diff --git a/console/Console.py b/console/Console.py
index 20e5dab8..9582174e 100644
--- a/console/Console.py
+++ b/console/Console.py
@@ -75,8 +75,8 @@ class ConsoleWidget(QtGui.QWidget):
self.ui.clearExceptionBtn.clicked.connect(self.clearExceptionClicked)
self.ui.exceptionStackList.itemClicked.connect(self.stackItemClicked)
self.ui.exceptionStackList.itemDoubleClicked.connect(self.stackItemDblClicked)
+ self.ui.onlyUncaughtCheck.toggled.connect(self.updateSysTrace)
- self.exceptionHandlerRunning = False
self.currentTraceback = None
def loadHistory(self):
@@ -235,10 +235,10 @@ class ConsoleWidget(QtGui.QWidget):
self.ui.catchAllExceptionsBtn.setChecked(catch)
if catch:
self.ui.catchNextExceptionBtn.setChecked(False)
- exceptionHandling.register(self.allExceptionsHandler)
+ self.enableExceptionHandling()
self.ui.exceptionBtn.setChecked(True)
else:
- exceptionHandling.unregister(self.allExceptionsHandler)
+ self.disableExceptionHandling()
def catchNextException(self, catch=True):
"""
@@ -248,11 +248,18 @@ class ConsoleWidget(QtGui.QWidget):
self.ui.catchNextExceptionBtn.setChecked(catch)
if catch:
self.ui.catchAllExceptionsBtn.setChecked(False)
- exceptionHandling.register(self.nextExceptionHandler)
+ self.enableExceptionHandling()
self.ui.exceptionBtn.setChecked(True)
else:
- exceptionHandling.unregister(self.nextExceptionHandler)
+ self.disableExceptionHandling()
+ def enableExceptionHandling(self):
+ exceptionHandling.register(self.exceptionHandler)
+ self.updateSysTrace()
+
+ def disableExceptionHandling(self):
+ exceptionHandling.unregister(self.exceptionHandler)
+ self.updateSysTrace()
def clearExceptionClicked(self):
self.currentTraceback = None
@@ -275,14 +282,35 @@ class ConsoleWidget(QtGui.QWidget):
subprocess.Popen(self.editor.format(fileName=fileName, lineNum=lineNum), shell=True)
- def allExceptionsHandler(self, *args):
- self.exceptionHandler(*args)
+ #def allExceptionsHandler(self, *args):
+ #self.exceptionHandler(*args)
- def nextExceptionHandler(self, *args):
- self.ui.catchNextExceptionBtn.setChecked(False)
- self.exceptionHandler(*args)
+ #def nextExceptionHandler(self, *args):
+ #self.ui.catchNextExceptionBtn.setChecked(False)
+ #self.exceptionHandler(*args)
+ def updateSysTrace(self):
+ ## Install or uninstall sys.settrace handler
+
+ if not self.ui.catchNextExceptionBtn.isChecked() and not self.ui.catchAllExceptionsBtn.isChecked():
+ if sys.gettrace() == self.systrace:
+ sys.settrace(None)
+ return
+
+ if self.ui.onlyUncaughtCheck.isChecked():
+ if sys.gettrace() == self.systrace:
+ sys.settrace(None)
+ else:
+ if sys.gettrace() is not None and sys.gettrace() != self.systrace:
+ self.ui.onlyUncaughtCheck.setChecked(False)
+ raise Exception("sys.settrace is in use; cannot monitor for caught exceptions.")
+ else:
+ sys.settrace(self.systrace)
+
def exceptionHandler(self, excType, exc, tb):
+ if self.ui.catchNextExceptionBtn.isChecked():
+ self.ui.catchNextExceptionBtn.setChecked(False)
+
self.ui.clearExceptionBtn.setEnabled(True)
self.currentTraceback = tb
@@ -291,14 +319,9 @@ class ConsoleWidget(QtGui.QWidget):
self.ui.exceptionStackList.clear()
for index, line in enumerate(traceback.extract_tb(tb)):
self.ui.exceptionStackList.addItem('File "%s", line %s, in %s()\n %s' % line)
-
- def quit(self):
- if self.exceptionHandlerRunning:
- self.exitHandler = True
- try:
- exceptionHandling.unregister(self.exceptionHandler)
- except:
- pass
-
-
\ No newline at end of file
+ def systrace(self, frame, event, arg):
+ if event == 'exception':
+ self.exceptionHandler(*arg)
+ return self.systrace
+
\ No newline at end of file
diff --git a/console/template.py b/console/template.py
index 42e9e6ed..ebdb8ab2 100644
--- a/console/template.py
+++ b/console/template.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
-# Form implementation generated from reading ui file './lib/modules/Console/template.ui'
+# Form implementation generated from reading ui file 'template.ui'
#
-# Created: Wed Jun 6 12:46:30 2012
+# Created: Mon Aug 20 22:49:47 2012
# by: PyQt4 UI code generator 4.9.1
#
# WARNING! All changes made in this file will be lost!
@@ -62,43 +62,50 @@ class Ui_Form(object):
self.gridLayout_2.setSpacing(0)
self.gridLayout_2.setContentsMargins(-1, 0, -1, 0)
self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
- self.catchNextExceptionBtn = QtGui.QPushButton(self.exceptionGroup)
- self.catchNextExceptionBtn.setCheckable(True)
- self.catchNextExceptionBtn.setObjectName(_fromUtf8("catchNextExceptionBtn"))
- self.gridLayout_2.addWidget(self.catchNextExceptionBtn, 0, 0, 1, 1)
- self.exceptionStackList = QtGui.QListWidget(self.exceptionGroup)
- self.exceptionStackList.setAlternatingRowColors(True)
- self.exceptionStackList.setObjectName(_fromUtf8("exceptionStackList"))
- self.gridLayout_2.addWidget(self.exceptionStackList, 2, 0, 1, 3)
self.catchAllExceptionsBtn = QtGui.QPushButton(self.exceptionGroup)
self.catchAllExceptionsBtn.setCheckable(True)
self.catchAllExceptionsBtn.setObjectName(_fromUtf8("catchAllExceptionsBtn"))
self.gridLayout_2.addWidget(self.catchAllExceptionsBtn, 0, 1, 1, 1)
- self.clearExceptionBtn = QtGui.QPushButton(self.exceptionGroup)
- self.clearExceptionBtn.setEnabled(False)
- self.clearExceptionBtn.setObjectName(_fromUtf8("clearExceptionBtn"))
- self.gridLayout_2.addWidget(self.clearExceptionBtn, 0, 2, 1, 1)
+ self.catchNextExceptionBtn = QtGui.QPushButton(self.exceptionGroup)
+ self.catchNextExceptionBtn.setCheckable(True)
+ self.catchNextExceptionBtn.setObjectName(_fromUtf8("catchNextExceptionBtn"))
+ self.gridLayout_2.addWidget(self.catchNextExceptionBtn, 0, 0, 1, 1)
+ self.onlyUncaughtCheck = QtGui.QCheckBox(self.exceptionGroup)
+ self.onlyUncaughtCheck.setChecked(True)
+ self.onlyUncaughtCheck.setObjectName(_fromUtf8("onlyUncaughtCheck"))
+ self.gridLayout_2.addWidget(self.onlyUncaughtCheck, 0, 2, 1, 1)
+ self.exceptionStackList = QtGui.QListWidget(self.exceptionGroup)
+ self.exceptionStackList.setAlternatingRowColors(True)
+ self.exceptionStackList.setObjectName(_fromUtf8("exceptionStackList"))
+ self.gridLayout_2.addWidget(self.exceptionStackList, 2, 0, 1, 5)
self.runSelectedFrameCheck = QtGui.QCheckBox(self.exceptionGroup)
self.runSelectedFrameCheck.setChecked(True)
self.runSelectedFrameCheck.setObjectName(_fromUtf8("runSelectedFrameCheck"))
- self.gridLayout_2.addWidget(self.runSelectedFrameCheck, 3, 0, 1, 3)
+ self.gridLayout_2.addWidget(self.runSelectedFrameCheck, 3, 0, 1, 5)
self.exceptionInfoLabel = QtGui.QLabel(self.exceptionGroup)
self.exceptionInfoLabel.setObjectName(_fromUtf8("exceptionInfoLabel"))
- self.gridLayout_2.addWidget(self.exceptionInfoLabel, 1, 0, 1, 3)
+ self.gridLayout_2.addWidget(self.exceptionInfoLabel, 1, 0, 1, 5)
+ self.clearExceptionBtn = QtGui.QPushButton(self.exceptionGroup)
+ self.clearExceptionBtn.setEnabled(False)
+ self.clearExceptionBtn.setObjectName(_fromUtf8("clearExceptionBtn"))
+ self.gridLayout_2.addWidget(self.clearExceptionBtn, 0, 4, 1, 1)
+ spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+ self.gridLayout_2.addItem(spacerItem, 0, 3, 1, 1)
self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
- Form.setWindowTitle(QtGui.QApplication.translate("Console", "Console", None, QtGui.QApplication.UnicodeUTF8))
+ Form.setWindowTitle(QtGui.QApplication.translate("Form", "Console", None, QtGui.QApplication.UnicodeUTF8))
self.historyBtn.setText(QtGui.QApplication.translate("Form", "History..", None, QtGui.QApplication.UnicodeUTF8))
self.exceptionBtn.setText(QtGui.QApplication.translate("Form", "Exceptions..", None, QtGui.QApplication.UnicodeUTF8))
self.exceptionGroup.setTitle(QtGui.QApplication.translate("Form", "Exception Handling", None, QtGui.QApplication.UnicodeUTF8))
- self.catchNextExceptionBtn.setText(QtGui.QApplication.translate("Form", "Catch Next Exception", None, QtGui.QApplication.UnicodeUTF8))
- self.catchAllExceptionsBtn.setText(QtGui.QApplication.translate("Form", "Catch All Exceptions", None, QtGui.QApplication.UnicodeUTF8))
- self.clearExceptionBtn.setText(QtGui.QApplication.translate("Form", "Clear Exception", None, QtGui.QApplication.UnicodeUTF8))
+ self.catchAllExceptionsBtn.setText(QtGui.QApplication.translate("Form", "Show All Exceptions", None, QtGui.QApplication.UnicodeUTF8))
+ self.catchNextExceptionBtn.setText(QtGui.QApplication.translate("Form", "Show Next Exception", None, QtGui.QApplication.UnicodeUTF8))
+ self.onlyUncaughtCheck.setText(QtGui.QApplication.translate("Form", "Only Uncaught Exceptions", None, QtGui.QApplication.UnicodeUTF8))
self.runSelectedFrameCheck.setText(QtGui.QApplication.translate("Form", "Run commands in selected stack frame", None, QtGui.QApplication.UnicodeUTF8))
self.exceptionInfoLabel.setText(QtGui.QApplication.translate("Form", "Exception Info", None, QtGui.QApplication.UnicodeUTF8))
+ self.clearExceptionBtn.setText(QtGui.QApplication.translate("Form", "Clear Exception", None, QtGui.QApplication.UnicodeUTF8))
from .CmdInput import CmdInput
diff --git a/console/template.ui b/console/template.ui
index 42adfaad..6e5c5be3 100644
--- a/console/template.ui
+++ b/console/template.ui
@@ -89,27 +89,20 @@
0
- -
-
+
-
+
- Catch Next Exception
+ Show All Exceptions
true
- -
-
-
- true
-
-
-
- -
-
+
-
+
- Catch All Exceptions
+ Show Next Exception
true
@@ -117,16 +110,23 @@
-
-
-
- false
-
+
- Clear Exception
+ Only Uncaught Exceptions
+
+
+ true
- -
+
-
+
+
+ true
+
+
+
+ -
Run commands in selected stack frame
@@ -136,13 +136,36 @@
- -
+
-
Exception Info
+ -
+
+
+ false
+
+
+ Clear Exception
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+