ID 373363 - Exceptions when clicking into various tabs after creation of a GafferThree package fails

Follow

Problem summary:

After the creation of a GafferThree package via choosing a context menu item fails, mouse events are wrongly sent to widgets in Katana tabs as QContextMenuEvent objects, rather than QMouseEvent objects, leading to exceptions in various places in the codebase, making it impossible to continue working with the current UI session.

Steps to reproduce:

  1. Create a file named BrokenGafferThreePackage.py in your .katana/Plugins/ folder with the following contents:
    • 
      from Katana import Pluginsfrom PackageSuperToolAPI import Packagesfrom PackageSuperToolAPI import UIDelegateGafferThreeAPI = Plugins.GafferThreeAPILightPackage = GafferThreeAPI.PackageClasses.LightPackageclass BrokenLightPackage(LightPackage):    DISPLAY_NAME = 'Broken Light'    DEFAULT_NAME = 'brokenLight'    @classmethod    def create(cls, enclosingNode, locationPath):        """        A factory method which returns an instance of the class.        @type enclosingNode: C{NodegraphAPI.Node}        @type locationPath: C{str}        @rtype: L{LightPackage}        @param enclosingNode: The parent node within which the new            package's node should be created.        @param locationPath: The path to the location to be created/managed            by the package.        @return: The newly-created package instance.        """        raise RuntimeError('Could not create broken light.')class BrokenLightUIDelegate(UIDelegate.UIDelegate):    # Class Variables ---------------------------------------------------------    # The hash used to uniquely identify the action of creating a package    AddPackageActionHash = 'f13cb32eb08c88e9bbba9229912c44c3'    # The keyboard shortcut for creating a package    DefaultShortcut = 'H'GafferThreeAPI.RegisterPackageClass(BrokenLightPackage)UIDelegate.RegisterUIDelegateClass(BrokenLightPackage, BrokenLightUIDelegate)
  2. Start Katana.
  3. In the Node Graph tab, create a GafferThree node and set its edit flag.
  4. In the Parameters tab, right-click into the table of objects of the edited GafferThree node, and choose Add > Broken Light from the context menu.
  5. Note that creating the broken light fails with an error message.
  6. Move the pointer back over the Node Graph, Monitor, Viewer (Hydra), UV Viewer, or Viewer tab's canvas, and click the left, middle, or right mouse button.

Expected behaviour:

Mouse button presses are registered correctly and acted upon.

Actual behaviour:

Python exceptions are raised, with tracebacks similar to the following:


[ERROR python.root]: An AttributeError occurred in "OffscreenFlagDisplayLayer.py": 'QContextMenuEvent' object has no attribute 'button'    Traceback (most recent call last):      File "bin/python/UI4/Tabs/NodeGraphTab/NodegraphWidget.py", line 894, in event      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 685, in event      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 805, in __delegateEvent      File "bin/python/UI4/Tabs/NodeGraphTab/Layers/OffscreenFlagDisplayLayer.py", line 36, in processEvent    AttributeError: 'QContextMenuEvent' object has no attribute 'button'

[ERROR python.root]: An AttributeError occurred in "StickyNoteInteractionLayer.py": 'QContextMenuEvent' object has no attribute 'button'    Traceback (most recent call last):      File "bin/python/UI4/Tabs/NodeGraphTab/NodegraphWidget.py", line 894, in event      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 685, in event      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 805, in __delegateEvent      File "bin/python/UI4/Tabs/NodeGraphTab/Layers/StickyNoteInteractionLayer.py", line 178, in processEvent    AttributeError: 'QContextMenuEvent' object has no attribute 'button'

[ERROR python.root]: An AttributeError occurred in "ZoomInteractionLayer.py": 'QContextMenuEvent' object has no attribute 'button'    Traceback (most recent call last):      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 685, in event      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 805, in __delegateEvent      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/ZoomInteractionLayer.py", line 75, in processEvent    AttributeError: 'QContextMenuEvent' object has no attribute 'button'

[ERROR python.root]: An AttributeError occurred in "RenderFocusLayer.py": 'QContextMenuEvent' object has no attribute 'button'    Traceback (most recent call last):      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 685, in event      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 805, in __delegateEvent      File "bin/python/UI4/Tabs/Monitor/Layers/RenderFocusLayer.py", line 73, in processEvent    AttributeError: 'QContextMenuEvent' object has no attribute 'button'

[ERROR python.root]: An AttributeError occurred in "ContextMenuLayer.py": 'QContextMenuEvent' object has no attribute 'button'    Traceback (most recent call last):      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 685, in event      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 805, in __delegateEvent      File "bin/python/UI4/Tabs/OSGViewerTab/Layers/ContextMenuLayer.py", line 42, in processEvent    AttributeError: 'QContextMenuEvent' object has no attribute 'button'

[ERROR python.root]: An AttributeError occurred in "HUDLayer.py": 'QContextMenuEvent' object has no attribute 'button'    Traceback (most recent call last):      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 685, in event      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 805, in __delegateEvent      File "bin/python/UI4/Tabs/OSGViewerTab/Layers/HUDLayer.py", line 264, in processEvent    AttributeError: 'QContextMenuEvent' object has no attribute 'button'

[ERROR python.root]: An AttributeError occurred in "EventTranslators.py": 'QContextMenuEvent' object has no attribute 'button'    Traceback (most recent call last):      File "bin/python/UI4/Widgets/ViewportWidget.py", line 302, in event      File "plugins/Resources/Core/UIPlugins/GenericViewerPlugins/EventTranslators.py", line 60, in Translate    AttributeError: 'QContextMenuEvent' object has no attribute 'button'

[ERROR python.root]: An AttributeError occurred in "ViewportWidget.py": 'QContextMenuEvent' object has no attribute 'button'    Traceback (most recent call last):      File "bin/python/UI4/Widgets/ViewportWidget.py", line 292, in event    AttributeError: 'QContextMenuEvent' object has no attribute 'button'

[ERROR python.root]: A TypeError occurred in "Events.py": arguments did not match any overloaded call:      QMouseEvent(QEvent.Type, Union[QPointF, QPoint], Qt.MouseButton, Union[Qt.MouseButtons, Qt.MouseButton], Union[Qt.KeyboardModifiers, Qt.KeyboardModifier]): argument 1 has unexpected type 'QContextMenuEvent'      QMouseEvent(QEvent.Type, Union[QPointF, QPoint], Union[QPointF, QPoint], Qt.MouseButton, Union[Qt.MouseButtons, Qt.MouseButton], Union[Qt.KeyboardModifiers, Qt.KeyboardModifier]): argument 1 has unexpected type 'QContextMenuEvent'      QMouseEvent(QEvent.Type, Union[QPointF, QPoint], Union[QPointF, QPoint], Union[QPointF, QPoint], Qt.MouseButton, Union[Qt.MouseButtons, Qt.MouseButton], Union[Qt.KeyboardModifiers, Qt.KeyboardModifier]): argument 1 has unexpected type 'QContextMenuEvent'      QMouseEvent(QEvent.Type, Union[QPointF, QPoint], Union[QPointF, QPoint], Union[QPointF, QPoint], Qt.MouseButton, Union[Qt.MouseButtons, Qt.MouseButton], Union[Qt.KeyboardModifiers, Qt.KeyboardModifier], Qt.MouseEventSource): argument 1 has unexpected type 'QContextMenuEvent'      QMouseEvent(QMouseEvent): argument 1 has unexpected type 'QContextMenuEvent'    Traceback (most recent call last):      File "bin/python/UI4/Tabs/DopeSheet/KeyLayerStack.py", line 280, in event      File "bin/python/UI4/Util/Events.py", line 125, in process    TypeError: arguments did not match any overloaded call:      QMouseEvent(QEvent.Type, Union[QPointF, QPoint], Qt.MouseButton, Union[Qt.MouseButtons, Qt.MouseButton], Union[Qt.KeyboardModifiers, Qt.KeyboardModifier]): argument 1 has unexpected type 'QContextMenuEvent'      QMouseEvent(QEvent.Type, Union[QPointF, QPoint], Union[QPointF, QPoint], Qt.MouseButton, Union[Qt.MouseButtons, Qt.MouseButton], Union[Qt.KeyboardModifiers, Qt.KeyboardModifier]): argument 1 has unexpected type 'QContextMenuEvent'      QMouseEvent(QEvent.Type, Union[QPointF, QPoint], Union[QPointF, QPoint], Union[QPointF, QPoint], Qt.MouseButton, Union[Qt.MouseButtons, Qt.MouseButton], Union[Qt.KeyboardModifiers, Qt.KeyboardModifier]): argument 1 has unexpected type 'QContextMenuEvent'      QMouseEvent(QEvent.Type, Union[QPointF, QPoint], Union[QPointF, QPoint], Union[QPointF, QPoint], Qt.MouseButton, Union[Qt.MouseButtons, Qt.MouseButton], Union[Qt.KeyboardModifiers, Qt.KeyboardModifier], Qt.MouseEventSource): argument 1 has unexpected type 'QContextMenuEvent'      QMouseEvent(QMouseEvent): argument 1 has unexpected type 'QContextMenuEvent'

[ERROR python.root]: An AttributeError occurred in "PanInteractionLayer.py": 'QContextMenuEvent' object has no attribute 'button'    Traceback (most recent call last):      File "bin/python/UI4/Tabs/UVPanel/UVWidget.py", line 1239, in event      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 685, in event      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/LayerStack.py", line 805, in __delegateEvent      File "bin/python/UI4/software_python/QT4GLLayerStack/v0/PanInteractionLayer.py", line 55, in processEvent    AttributeError: 'QContextMenuEvent' object has no attribute 'button'

Workaround:

Fixing the original exception inside of the custom package type's code should avoid the issues with QContextMenuEvent objects being processed instead of QMouseEvent objects.

Tested versions/platforms:

  • 3.0v6/Linux - Unaffected
  • 3.1v1/Linux - Affected

Customer version/platform:

3.1v1/Linux (Ubuntu 16.04)

    We're sorry to hear that

    Please tell us why