Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1360

Model QProgressDialog jams when updated from separate thread

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 5.15.0
    • PySide
    • None
    • Windows 10, PySide2 5.15.0, Python 3.7.8. Pyside installed via pip.
    • Windows

    Description

      A QProgressDialog updated by a QThread via signals will often jam if the updates are emitted relatively frequently (5-10 times a second). The QProgressDialog will stop updating and stick on one value. If this happens, it will remain jammed for some time after the thread has finished its work. It will eventually come back to life and close properly.

      This issue is unpredictable. It will jam at different points each time and occasionally it will make it through without stopping. If I do not set the QProgressBar modality to WindowModal, it works without issue.

      The issue does not appear to exist in Pyside2 5.14.2.3.

      This is a minimal example:

      from PySide2 import QtWidgets, QtCore
      import time
      import sys
      
      
      class SomeWidget(QtWidgets.QWidget):    def __init__(self, parent=None):
              super(SomeWidget, self).__init__(parent)
              self.thread = QtCore.QThread()
              
              self.progress = QtWidgets.QProgressDialog("", "Cancel", 0, 100, self)
              self.progress.setWindowModality(QtCore.Qt.WindowModal)
              self.progress.setAutoClose(True)
              self.progress.setAutoReset(True)
              
              self.worker = Worker()
              self.worker.moveToThread(self.thread)
              self.worker.update_progress.connect(self.progress.setValue)
              self.worker.done.connect(self.work_done)
              self.thread.started.connect(self.worker.do_the_thing)
          
              self.thread.start()
              
          def work_done(self):
              self.thread.exit()
              print("Done")
      
      class Worker(QtCore.QObject):
          update_progress = QtCore.Signal(int)
          done = QtCore.Signal()
          
          def do_the_thing(self):
              for ii in range(1, 101):
                  time.sleep(0.1)  # Simulate work
                  self.update_progress.emit(ii)
              self.done.emit()
      
      
      app = QtWidgets.QApplication()
      widget = SomeWidget()
      widget.show()
      sys.exit(app.exec_())
      

       

       

       

      Attachments

        1. pyside-1360.mp4
          216 kB
        2. pyside1360.py
          1 kB
        3. PySide2-bug.mp4
          4.89 MB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            wjwilson William Wilson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes