In PySide I have the following MainWindow definition:

Qt Code:
  1. class MainWindow(QtGui.QMainWindow):
  2. def __init__(self, parent=None):
  3. super(MainWindow, self).__init__(parent)
  5. self.view = QtGui.QListView(self)
  6. self.model = QtGui.QStandardItemModel()
  7. for i in range(10):
  8. self.model.setItem(i, QtGui.QStandardItem("Item {0}".format(i)))
  10. self.view.setModel(self.model)
  11. self.view.selectionModel().selectionChanged.connect(self._selectionChanged)
  13. self.setCentralWidget(self.view)
  15. def _selectionChanged(self,selected, deselected):
  16. pass
To copy to clipboard, switch view to plain text mode 

When I try and connect the selectionChanged signal I crash python. It's the same as this SO post and the workaround suggestion of keeping the selection model around seems to work.

Qt Code:
  1. self.viewselectionModel = self.view.selectionModel()
  2. self.viewselectionModel.selectionChanged.connect(self._selectionChanged)
To copy to clipboard, switch view to plain text mode 

But is this safe? And is this an official bug in PySide? I could not find anything in the bug report database.