diff --git a/Changes.md b/Changes.md index 03df03588a..a38e94baf2 100644 --- a/Changes.md +++ b/Changes.md @@ -10,6 +10,13 @@ Improvements - PlugPopup : Improved default popup title. Plugs and non-viewable nodes are no longer included in the title. - Viewer : Added D hotkey for toggling between denoised and undenoised layers. +Fixes +----- + +- PlugLayout : + - Fixed `Internal C++ object already deleted` errors when removing "layout:accessory" metadata from plugs currently visible in the Node Editor. + - Fixed layout issues when combining "layout:divider" and "layout:accessory" metadata. + API --- diff --git a/python/GafferUI/PlugLayout.py b/python/GafferUI/PlugLayout.py index b387060236..3b4eabbb27 100644 --- a/python/GafferUI/PlugLayout.py +++ b/python/GafferUI/PlugLayout.py @@ -330,14 +330,26 @@ def __updateLayout( self ) : section = section.subsection( sectionName ) if len( section.widgets ) and self.__itemMetadataValue( item, "accessory" ) : - if isinstance( section.widgets[-1], _AccessoryRow ) : - section.widgets[-1].append( widget ) + primaryIndex = -1 + for i in range( len( section.widgets ) - 1, -1, -1 ) : + if not isinstance( section.widgets[i], GafferUI.Divider ) : + primaryIndex = i + break + + if isinstance( section.widgets[primaryIndex], _AccessoryRow ) : + section.widgets[primaryIndex].append( widget ) else : row = _AccessoryRow() - row.append( section.widgets[-1] ) + row.append( section.widgets[primaryIndex] ) row.append( widget ) - section.widgets[-1] = row + section.widgets[primaryIndex] = row else : + parent = widget.parent() + if isinstance( parent, _AccessoryRow ) : + # Widget is no longer an accessory or no longer has an accessory, reparent to + # grandparent to prevent the widget from being deleted with the old _AccessoryRow. + parent.parent().addChild( widget ) + section.widgets.append( widget ) if self.__itemMetadataValue( item, "divider" ) :