Skip to content

Commit

Permalink
ShufflePlug : Fix fail to create dests with fallback identity shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldresser-ie committed Jul 5, 2024
1 parent af3bb46 commit d7c924b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Fixes
- UVInspector : Fixed `Unable to find ScriptNode for UVView` warnings.
- Scene Editors : Fixed update when ScenePlugs are added to or removed from the node being viewed.
- PrimitiveInspector : Fixed failure to update when the location being viewed ceases to exist, or is recreated.
- Shuffle : Fixed very specific bug where ensuring a channel exists by shuffling "channelName" to "channelName" with `missingSourceMode` set to black would fail to create the channel if it didn't already exist.

API
---
Expand Down
5 changes: 4 additions & 1 deletion include/Gaffer/ShufflePlug.inl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ T ShufflesPlug::shuffleInternal( const T &sourceContainer, const T *extraSources
const std::string &srcName = srcPattern;
const typename T::mapped_type *srcValue = nullptr;
typename T::const_iterator sIt = sourceContainer.find( srcName );
bool usingExtraSource = false;

if( sIt != sourceContainer.end() )
{
srcValue = &sIt->second;
Expand All @@ -131,6 +133,7 @@ T ShufflesPlug::shuffleInternal( const T &sourceContainer, const T *extraSources
if( sIt != extraSources->end() )
{
srcValue = &sIt->second;
usingExtraSource = true;
}
}

Expand All @@ -142,7 +145,7 @@ T ShufflesPlug::shuffleInternal( const T &sourceContainer, const T *extraSources
if( ! dstPattern.empty() )
{
const std::string dstName = scope.context()->substitute( dstPattern );
if( srcName != dstName )
if( srcName != dstName || usingExtraSource )
{
if( dstReplace || ( destinationContainer.find( dstName ) == destinationContainer.end() ) )
{
Expand Down
5 changes: 5 additions & 0 deletions python/GafferTest/ShufflePlugTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,5 +526,10 @@ def testExtraSources( self ) :
self.assertEqual( plug.shuffleWithExtraSources( source, extraSources ), IECore.CompoundData( { "bar" : 20 } ) )
self.assertEqual( plug.shuffleWithExtraSources( source, extraSources, ignoreMissingSource = False ), IECore.CompoundData( { "bar" : 20 } ) )

# When using an extra source of `*`, we should be able to create a new value with a fallback by shuffling
# from "toto" to "toto"
plug[0]["destination"].setValue( "toto" )
self.assertEqual( plug.shuffleWithExtraSources( source, extraSources ), IECore.CompoundData( { "toto" : 20 } ) )

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

0 comments on commit d7c924b

Please sign in to comment.