<div>I believe I have run into a class of bugs in PyQt4. I originally found that QSpinBox.lineEdit() returns a QLineEdit instance which does not maintain its reference count properly after the original QSpinBox is deleted. Thus it is possible to either 1) have uncollectable LineEdits lingering in memory, or 2) crash the program by accessing the LineEdit (see example below). </div>
<div><br></div><div>The same bug also applies to:</div><div> - QAbstractSpinBox.lineEdit</div><div> - QComboBox.lineEdit, </div><div><div> - QAbstractScrollArea.horizontalScrollBar</div></div><div><div> - QAbstractScrollArea.verticalScrollBar</div>
</div><div> - QTreeView.header</div><div> - QSplitter.handle</div><div><br></div><div>.. and likely many others. In the best case, this bug causes minor memory leaks that few people are likely to notice. In the worst case, it causes crashes which are very difficult to debug if you don't have easy access to debugging symbols (ie using windows binaries). </div>
<div><br></div><div>$ python</div><div>>>> from PyQt4.QtGui import *</div><div>>>> a = QApplication([])</div><div>>>> s = QSpinBox()</div><div>>>> l = s.lineEdit()</div><div>>>> del s</div>
<div>>>> l.text()</div><div>Segmentation fault</div>