[PyQt] Puzzling crash after multiple calls to getOpenFileName

David Cortesi davecortesi at gmail.com
Mon Jun 9 22:07:00 BST 2014


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.

Here is a minimal test case, save as getopenfilename3.py and run under
Python 3.3:

  from PyQt5.QtCore import PYQT_VERSION_STR, QT_VERSION_STR
  print(PYQT_VERSION_STR,QT_VERSION_STR)
  from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog
  app = QApplication([])
  mw = QMainWindow()
  mw.show()
  (path, _) = QFileDialog.getOpenFileName(mw,'PRESS CANCEL','.','')
  print(1,path)
  (path, _) = QFileDialog.getOpenFileName(mw,'PRESS CANCEL','.','')
  print(2,path)
  (path, _) = QFileDialog.getOpenFileName(mw,'PRESS CANCEL','.','')
  print(3,path)
  (path, _) = QFileDialog.getOpenFileName(mw,'PRESS CANCEL','.','')
  print(4,path)

When I run this from the command line in one of my systems it runs just as
expected.

But on my other dev system, the output is usually:

  5.3 5.3.0
  1
  2
  pure virtual method calledAbort trap: 6

And a crash report showing thread 0 died in libsystem_kernel.dylib, with
QFileDialog the 29th item in the stack display.

The differences between the two systems:

Where it works: Mac OS 10.9, Qt 5.2 and PyQt 5.2

Where it crashes: Mac OS 10.7 but Qt 5.3.0 and PyQt 5.3

Thanks for your time,
Dave Cortesi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140609/6074c66a/attachment.html>


More information about the PyQt mailing list