Skip to content

Commit

Permalink
Merge pull request #6169 from johnhaddon/gadgetWidgetFix
Browse files Browse the repository at this point in the history
GadgetWidget : Fix signal handling bug
  • Loading branch information
johnhaddon authored Dec 10, 2024
2 parents dc38e12 + 6d0ae46 commit f3b7898
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Fixes
- GraphEditor : Fixed errors when dragging an unknown file type into the GraphEditor.
- Widget : Fixed `event.sourceWidget` for DragDropEvents generated from a Qt native drag within the same Gaffer process. This will now reference the `GafferUI.Widget` that the Qt source widget belongs to, if any.
- Catalogue : Fixed bug which "stole" drags that crossed the image listing but which were destined elsewhere, for instance a drag from the HierarchyView to a PathFilter in the GraphEditor.
- GadgetWidget : Fixed signal handling bug in `setViewportGadget()`. This could cause the widget to attempt to redraw unnecessarily when the _old_ viewport requested a redraw.

1.4.15.2 (relative to 1.4.15.1)
========
Expand Down
2 changes: 1 addition & 1 deletion python/GafferUI/GadgetWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def setViewportGadget( self, viewportGadget ) :
self.__viewportGadget.setVisible( False )

self.__viewportGadget = viewportGadget
self.__viewportGadget.renderRequestSignal().connect( Gaffer.WeakMethod( self.__renderRequest ), scoped = False )
self.__renderRequestConnection = self.__viewportGadget.renderRequestSignal().connect( Gaffer.WeakMethod( self.__renderRequest ), scoped = True )
size = self.size()
if size.x and size.y :
self.__viewportGadget.setViewport( size )
Expand Down
13 changes: 13 additions & 0 deletions python/GafferUITest/GadgetWidgetTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,18 @@ def testViewportVisibility( self ) :
self.assertFalse( vg1.visible() )
self.assertFalse( vg2.visible() )

def testConnectionLifetime( self ) :

gadgetWidget = GafferUI.GadgetWidget()
viewportGadget1 = gadgetWidget.getViewportGadget()
self.assertEqual( viewportGadget1.renderRequestSignal().numSlots(), 1 )

viewportGadget2 = GafferUI.ViewportGadget()
self.assertEqual( viewportGadget2.renderRequestSignal().numSlots(), 0 )

gadgetWidget.setViewportGadget( viewportGadget2 )
self.assertEqual( viewportGadget1.renderRequestSignal().numSlots(), 0 )
self.assertEqual( viewportGadget2.renderRequestSignal().numSlots(), 1 )

if __name__ == "__main__":
unittest.main()

0 comments on commit f3b7898

Please sign in to comment.