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

Raising exception in mouseReleaseEvent breaks contextMenuEvent

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.9
    • Fix Version/s: None
    • Component/s: PySide
    • Labels:
    • Environment:
      Python 2.7.13

      PySide2

      Qt 5.9.1

      Cent6

      Description

       

      """
      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

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

          Activity

            People

            • Assignee:
              ctismer Christian Tismer
              Reporter:
              rafesacks Rafe Sacks
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Gerrit Reviews

                There are no open Gerrit changes