<div dir="ltr"><div><div><div><div><div><div><div><div><div>Ordinarily I wouldn't call QFileDialog.getOpenFileName multiple times, but in writing a unit test driver, I did code just that, and found it could crash Python usually on the third call in rapid succession.<br>
<br>Here is a minimal test case, save as getopenfilename3.py and run under Python 3.3:<br><br> from PyQt5.QtCore import PYQT_VERSION_STR, QT_VERSION_STR<br> print(PYQT_VERSION_STR,QT_VERSION_STR)<br> from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog<br>
app = QApplication([])<br> mw = QMainWindow()<br> mw.show()<br> (path, _) = QFileDialog.getOpenFileName(mw,'PRESS CANCEL','.','')<br> print(1,path)<br> (path, _) = QFileDialog.getOpenFileName(mw,'PRESS CANCEL','.','')<br>
print(2,path)<br> (path, _) = QFileDialog.getOpenFileName(mw,'PRESS CANCEL','.','')<br> print(3,path)<br> (path, _) = QFileDialog.getOpenFileName(mw,'PRESS CANCEL','.','')<br>
print(4,path)<br>
<br></div>When I run this from the command line in one of my systems it runs just as expected.<br><br></div>But on my other dev system, the output is usually:<br><br> 5.3 5.3.0<br> 1 <br> 2 <br> pure virtual method calledAbort trap: 6<br>
<br></div>And a crash report showing thread 0 died in libsystem_kernel.dylib, with QFileDialog the 29th item in the stack display.<br><br></div>The differences between the two systems:<br></div><br>Where it works: Mac OS 10.9, Qt 5.2 and PyQt 5.2<br>
</div><br>Where it crashes: Mac OS 10.7 but Qt 5.3.0 and PyQt 5.3<br></div><br>Thanks for your time,<br></div></div>Dave Cortesi<br></div>