Skip to content

Commit

Permalink
VectorDataPlugValueWidget : Single value drop
Browse files Browse the repository at this point in the history
Previously, we were letting `PlugValueWidget` attempt to convert dropped
data into something the target plug can support. When dropping a single
value such as `IntData` onto a `VectorDataPlugValueWidget`, this meant
converting `IntData` to `IntVectorData`. `*VectorData` supports
construction from an integer value, in which case it creates n elements
in the vector.

This commit instead converts a non-sequence value into a single item
sequence holding that value to use as drop data.
  • Loading branch information
ericmehl committed Jan 29, 2025
1 parent a4ae1cf commit 3b191b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Fixes
-----

- VectorDataWidget : Fixed bug preventing dropping a single value onto the `+` and `-` buttons.
- VectorDataWidget, VectorDataPlugValueWidget : Fixed bug preventing dropping a single value onto the `+` and `-` buttons and the plug name.

1.4.15.5 (relative to 1.4.15.4)
========
Expand Down
11 changes: 11 additions & 0 deletions python/GafferUI/VectorDataPlugValueWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ def __dataChanged( self, widget ) :
for plug, value in zip( self.__dataPlugs(), self.__dataWidget.getData() ) :
plug.setValue( value )

def _convertValue( self, value ) :

plugValueType = type( self.getPlug().defaultValue() )
if hasattr( value, "value" ) and isinstance(
value.value,
IECore.DataTraits.valueTypeFromSequenceType( plugValueType )
) :
return plugValueType( [ value.value ] )
else :
return GafferUI.PlugValueWidget._convertValue( self, value )

class _VectorDataWidget( GafferUI.VectorDataWidget ) :

def __init__( self, **kw ) :
Expand Down

0 comments on commit 3b191b3

Please sign in to comment.