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

QEvents stop getting processed when an unhandled Python exception is set

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: dev
    • Fix Version/s: dev
    • Component/s: PySide
    • Labels:

      Description

      Found this using the example posted in
      https://codereview.qt-project.org/#/c/185481/

      import sys
      from PySide2 import QtCore, QtWidgets
      
      def onClicked():
          noSuchFunction()
      
      app = QtWidgets.QApplication(sys.argv)
      button = QtWidgets.QPushButton("Button")
      button.clicked.connect(onClicked)
      button.show()
      sys.exit(app.exec_())
      
      

      The issue is that the onClicked callback instantiates a GlobalReceiverV2 object, and when the callback is called, "GlobalReceiverV2::qt_metacall" is invoked, which itself calls "SignalManager::callPythonMetaMethod", which sets a Python error because "noSuchFunction" does not exist.

      This error is never handled, and when a new QEvent is processed by the QApplication, the event gets skipped because "QApplicationWrapper::notify" checks if any python error occurred, and returns early.
      Effectively this means all further events are never processed, and the application becomes unresponsive.

      Now the proper fix for this case is to add python error handling code in "GlobalReceiverV2::qt_metacall".

      But it should also be considered to print errors in all the generated wrapper methods like in the beginning of "QApplicationWrapper::notify", so the user at least knows why the application is being unresponsive.

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                alexandru.croitor Alexandru Croitor
              • Votes:
                5 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes