Skip to content

Commit

Permalink
Recursion for plug add/remove dirty propagation.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Apr 2, 2015
1 parent 9fe278a commit f0096a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/Gaffer/Plug.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class Plug : public GraphComponent
private :

void parentChanged();
static void propagateDirtinessForParentChange( Plug *plugToDirty );

void setInput( PlugPtr input, bool setChildInputs, bool updateParentInput );
void setInputInternal( PlugPtr input, bool emit );
Expand Down
22 changes: 20 additions & 2 deletions src/Gaffer/Plug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void Plug::parentChanging( Gaffer::GraphComponent *newParent )
pushDirtyPropagationScope();
if( node() )
{
propagateDirtiness( this );
propagateDirtinessForParentChange( this );
}
}

Expand Down Expand Up @@ -519,13 +519,31 @@ void Plug::parentChanged()
{
// If a dynamic plug has been added to a
// node, we need to propagate dirtiness.
propagateDirtiness( this );
propagateDirtinessForParentChange( this );
}
// Pop the scope pushed in parentChanging().
popDirtyPropagationScope();
}
}

void Plug::propagateDirtinessForParentChange( Plug *plugToDirty )
{
// When a plug is reparented, we need to take into account
// all the descendants it brings with it, so we recurse to
// find them, propagating dirtiness at the leaves.
if( plugToDirty->children().size() )
{
for( PlugIterator it( plugToDirty ); it != it.end(); ++it )
{
propagateDirtinessForParentChange( it->get() );
}
}
else
{
propagateDirtiness( plugToDirty );
}
}

//////////////////////////////////////////////////////////////////////////
// Dirty propagation
//////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit f0096a7

Please sign in to comment.