[PyQt] why QCompleter(parent) is TransferBack?
Yuya Nishihara
yuya at tcha.org
Sat Nov 29 09:04:36 GMT 2014
Hi,
I'm getting random crash around QCompleter. The production code is not simple
but it roughly does:
app = QApplication([])
window = QMainWindow()
lineedit = QLineEdit(window)
window.setCentralWidget(lineedit)
completer = QCompleter(window)
completer.setModel(QDirModel(completer))
lineedit.setCompleter(completer)
window.show()
app.exec_()
I looked into PyQt source and found that QCompleter(parent) is not annotated
as TransferThis.
QCompleter(QObject *parent /TransferBack/ = 0);
QCompleter(QAbstractItemModel *model, QObject *parent /TransferThis/ = 0);
QCompleter(const QStringList &list, QObject *parent /TransferThis/ = 0);
So I've changed the above code as follows, and it seems the crash no longer
happen.
window.setCentralWidget(lineedit)
-completer = QCompleter(window)
+completer = QCompleter([], window)
completer.setModel(QDirModel(completer))
Is there a reason for setting TransferBack only to QCompleter(parent) ?
Platform: Debian sid amd64
PyQt: 4.11.2+dfsg-1
Regards,
More information about the PyQt
mailing list