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

Raising exception in mouseReleaseEvent breaks contextMenuEvent

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • None
    • 5.9
    • PySide
    • Python 2.7.13

      PySide2

      Qt 5.9.1

      Cent6
    • 3e5bfbff99334b8c15ee705079d5a7f0cfa371d5 (pyside/pyside-setup/dev) 4788127dca1f90c0a83cbf3016da708404eaad69 (pyside/pyside-setup/6.2)

    Description

       Steps to reproduce:

      • Left click
      • Right click,. note error below
        """
        Repro:
        1. Run `python tests/python/test_event_exception.py`
        2. Right-click and nothing bad happens
        3. Left click to cause exception
        4. Right-click and see event exception
        """
        from PySide2 import QtWidgets, QtCore
        
        class Widget(QtWidgets.QWidget):
        
            def mouseReleaseEvent(self, event):
                print("\nmouseReleaseEvent :: event type: %r" % type(event))
                if event.button() == QtCore.Qt.LeftButton:
                    raise Exception("FOO")
        
            def contextMenuEvent(self, event):
                print("contextMenuEvent :: event type: %r" % type(event))
                super(Widget, self).contextMenuEvent(event)
        
        app = QtWidgets.QApplication(["event_repro"])
        
        widget = Widget()
        widget.show()
        
        app.exec_()
        

         

      The exception produced:

      Traceback (most recent call last):
      File "tests/python/test_event_exception.py", line 38, in mouseReleaseEvent
        raise Exception("FOO")
      Exception: FOO

      then causes the exception the next time right-click is pressed

      Traceback (most recent call last):
        File "tests/python/test_event_exception.py", line 43, in contextMenuEvent
          super(Widget, self).contextMenuEvent(event)
      TypeError: 'PySide2.QtWidgets.QWidget.contextMenuEvent' called with wrong argument types:
        PySide2.QtWidgets.QWidget.contextMenuEvent(PySide2.QtGui.QMouseEvent)
      Supported signatures:
        PySide2.QtWidgets.QWidget.contextMenuEvent(PySide2.QtGui.QContextMenuEvent)
      

       

      Attachments

        For Gerrit Dashboard: PYSIDE-656
        # Subject Branch Project Status CR V

        Activity

          People

            ctismer Christian Tismer
            rafesacks Rafe Sacks
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: