Skip to content

Commit

Permalink
Merge pull request #977 from ivanimanishi/fixArrayPlugCortex8
Browse files Browse the repository at this point in the history
Fixed serialisation of non-dynamic ArrayPlugs.
  • Loading branch information
andrewkaufman committed Sep 2, 2014
2 parents 513cf14 + 16b6348 commit 48785a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions python/GafferTest/ArrayPlugTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ def testSerialisation( self ) :
s2 = Gaffer.ScriptNode()
s2.execute( s.serialise() )

self.assertEqual( len( s2["n"]["in"] ), 4 )
self.assertTrue( s2["n"]["in"]["e1"].isSame( s2["n"]["in"][0] ) )
self.assertTrue( s2["n"]["in"]["e2"].isSame( s2["n"]["in"][1] ) )
self.assertTrue( s2["n"]["in"]["e3"].isSame( s2["n"]["in"][2] ) )
self.assertTrue( s2["n"]["in"]["e4"].isSame( s2["n"]["in"][3] ) )

self.assertTrue( s2["n"]["in"]["e1"].getInput(), s2["a"]["sum"] )
self.assertTrue( s2["n"]["in"]["e2"].getInput() is None )
self.assertTrue( s2["n"]["in"]["e3"].getInput(), s2["a"]["sum"] )
self.assertTrue( s2["n"]["in"]["e4"].getInput() is None )

def testMaximumInputs( self ) :

a = GafferTest.AddNode()
Expand Down
8 changes: 7 additions & 1 deletion src/Gaffer/ArrayPlug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ ArrayPlug::ArrayPlug( const std::string &name, Direction direction, PlugPtr elem

if( element )
{
element->setFlags( Gaffer::Plug::Dynamic, true );
// If we're dynamic ourselves, then serialisations will include a constructor
// for us, but it will have element==None. In this case we make sure the first
// element is dynamic, so that it too will have a constructor written out (and then
// we'll capture it in childAdded()). But if we're not dynamic, we expect to be
// passed the element again upon reconstruction, so we don't need a constructor
// to be serialised for the element, and therefore we must set it to be non-dynamic.
element->setFlags( Gaffer::Plug::Dynamic, getFlags( Gaffer::Plug::Dynamic ) );
addChild( element );
}
else
Expand Down

0 comments on commit 48785a4

Please sign in to comment.