Details
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)