diff --git a/Changes.md b/Changes.md index a4efe389e4b..39be9716e95 100644 --- a/Changes.md +++ b/Changes.md @@ -18,7 +18,9 @@ Fixes ----- - Arnold : Fixed bug that caused `ai:volume:step_scale` to be ignored if `ai:volume_step` was set explicitly to `0.0`. This was different to the behaviour when `ai:volume_step` was not set at all. -- LightEditor : Fixed hang caused by the `soloLights` set triggering on an upstream Python expression or ComputeNode (#5365). +- LightEditor : + - Fixed hang caused by the `soloLights` set triggering on an upstream Python expression or ComputeNode (#5365). + - Fixed thread-safety bug that meant the LightEditor attempted to perform computes while the graph was being edited. - OSLImage : Fixed bug preventing channels / layers from being deleted using the right-click menu. - HierarchyView : Fixed crash triggered by layouts with two or more HierarchyViews (#5364). - Context : Fixed crash triggered by a reentrant call to `Context::set()` from within a slot connected to `Context::changedSignal()`. diff --git a/src/Gaffer/BackgroundTask.cpp b/src/Gaffer/BackgroundTask.cpp index 4dd7214fb72..8721e8f1015 100644 --- a/src/Gaffer/BackgroundTask.cpp +++ b/src/Gaffer/BackgroundTask.cpp @@ -60,6 +60,8 @@ namespace const ScriptNode *scriptNode( const GraphComponent *subject ) { + // Simple cases - there is no subject, or it is part of a script. + if( !subject ) { return nullptr; @@ -72,22 +74,32 @@ const ScriptNode *scriptNode( const GraphComponent *subject ) { return s; } - else + + // Special cases to accommodate the UI. + + // UI classes often house their own internal plugs which receive their input + // from nodes in the graph. Follow the inputs to see if we can find the + // graph. + if( auto p = runTimeCast( subject ) ) { - // Unfortunately the GafferUI::View classes house internal - // nodes which live outside any ScriptNode, but must still - // take part in cancellation. This hack recovers the ScriptNode - // for the node the view is currently connected to. - while( subject ) + if( auto s = scriptNode( p->getInput() ) ) { - if( subject->isInstanceOf( "GafferUI::View" ) ) - { - return scriptNode( subject->getChild( "in" )->getInput() ); - } - subject = subject->parent(); + return s; } - return nullptr; } + + // The `GafferUI::View` classes house internal nodes which might not be + // directly connected to the graph. This hack recovers the ScriptNode from + // the node the view is currently connected to. + while( subject ) + { + if( subject->isInstanceOf( "GafferUI::View" ) ) + { + return scriptNode( subject->getChild( "in" )->getInput() ); + } + subject = subject->parent(); + } + return nullptr; } struct ActiveTask