Skip to content

Commit

Permalink
Merge pull request #6068 from johnhaddon/backgroundTaskHack
Browse files Browse the repository at this point in the history
View/BackgroundTask : Improve ScriptNode discovery hack
  • Loading branch information
murraystevenson authored Oct 4, 2024
2 parents 7777d77 + 5019e9f commit b397954
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
4 changes: 3 additions & 1 deletion Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ Fixes
- Fixed partial image updates when an unrelated InteractiveRender was running (#6043).
- Fixed "colour tearing", where updates to some image channels became visible before updates to others.
- Fixed unnecessary texture updates when specific image tiles don't change.
- Viewer : Fixed drawing of custom mesh light texture visualisers (#6002). [^1]
- Viewer :
- Fixed drawing of custom mesh light texture visualisers (#6002). [^1]
- Fixed BackgroundTask warning when deleting the node being viewed.
- GraphEditor :
- Fixed lingering error badges (#3820).
- Fixed <kbd>D</kbd> shortcut to respect read-only metadata on `enabled` plugs. Previously only metadata on the node itself was respected.
Expand Down
9 changes: 2 additions & 7 deletions python/GafferSceneUITest/LightToolTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,8 @@ def testDeleteNodeCrash( self ) :
# we're pretty happy if it doesn't.

del preRenderSlot[:]
with IECore.CapturingMessageHandler() as mh :
while not len( preRenderSlot ) :
self.waitForIdle( 1000 )

# Ignore unrelated message from BackgroundTask. This needs a separate fix.
self.assertEqual( len( mh.messages ), 1 )
self.assertEqual( mh.messages[0].message, "Unable to find ScriptNode for SceneView.__preprocessor.out" )
while not len( preRenderSlot ) :
self.waitForIdle( 1000 )

if __name__ == "__main__" :
unittest.main()
9 changes: 1 addition & 8 deletions src/Gaffer/BackgroundTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,7 @@ const ScriptNode *scriptNode( const GraphComponent *subject )
// the ScriptNode from such classes.
while( subject )
{
if( subject->isInstanceOf( "GafferUI::View" ) )
{
if( auto inPlug = subject->getChild<Plug>( "in" ) )
{
return scriptNode( inPlug->getInput() );
}
}
else if( subject->isInstanceOf( "GafferUI::Editor::Settings" ) )
if( subject->isInstanceOf( "GafferUI::View" ) || subject->isInstanceOf( "GafferUI::Editor::Settings" ) )
{
if( auto scriptPlug = subject->getChild<Plug>( "__scriptNode" ) )
{
Expand Down
7 changes: 7 additions & 0 deletions src/GafferUI/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ View::View( const std::string &name, Gaffer::ScriptNodePtr scriptNode, Gaffer::P
addChild( new Plug( g_editScopeName ) );
addChild( new ToolContainer( g_toolsName ) );

// Hack to allow BackgroundTask to recover ScriptNode for
// cancellation support - see `BackgroundTask.cpp` and
// `Editor.Settings`.
PlugPtr scriptNodePlug = new Plug( "__scriptNode" );
addChild( scriptNodePlug );
scriptNodePlug->setInput( scriptNode->fileNamePlug() );

m_context = m_contextTracker->context( this );
m_contextTracker->changedSignal( this ).connect( boost::bind( &View::contextTrackerChanged, this ) );
tools()->childAddedSignal().connect( boost::bind( &View::toolsChildAdded, this, ::_2 ) );
Expand Down

0 comments on commit b397954

Please sign in to comment.