Dedenting function in QPlainTextEdit causes segfault if last line is involved
问题 I'm working on a source code editor that should have smart indent/dedent behaviour. However, my dedenting method seems to be causing a segmentation fault. I'd be very pleased if someone could work out why. Here's a minimal example: #!/usr/bin/env python import sip sip.setapi('QString', 2) sip.setapi('QVariant', 2) from PyQt4 import QtGui from PyQt4.QtCore import Qt class Editor(QtGui.QPlainTextEdit): def keyPressEvent(self, event): key = event.key() if key == Qt.Key_Backtab: cursor = self