From e78ec9bd7a4e3cf43c95562c6794d25058cffda3 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Wed, 18 Sep 2024 15:20:24 +0100 Subject: [PATCH] ImageGadget : Don't clear dirty flag after cancellation In most cases this didn't matter, because we were only getting cancelled by a graph edit which would eventually dirty the input plug anyway. But cancellation could be due to an edit in an unrelated part of the graph, in which case our input plug won't be dirtied again, but we do want to restart the update. Fixes #6043 --- Changes.md | 1 + src/GafferImageUI/ImageGadget.cpp | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Changes.md b/Changes.md index f5edcd6986..b94202547a 100644 --- a/Changes.md +++ b/Changes.md @@ -10,6 +10,7 @@ Fixes ----- - Viewer, ImageGadget : + - 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. - Constraint : The `target` browser now shows locations from the `targetScene` if it has an input connection. Before it always showed locations from the main input. diff --git a/src/GafferImageUI/ImageGadget.cpp b/src/GafferImageUI/ImageGadget.cpp index d7ee10afdd..dbb4c7add1 100644 --- a/src/GafferImageUI/ImageGadget.cpp +++ b/src/GafferImageUI/ImageGadget.cpp @@ -53,6 +53,7 @@ #include "Gaffer/BackgroundTask.h" #include "Gaffer/Context.h" #include "Gaffer/Node.h" +#include "Gaffer/Process.h" #include "Gaffer/ScriptNode.h" #include "IECore/MessageHandler.h" @@ -891,6 +892,7 @@ void ImageGadget::updateTiles() { m_tiles[TileIndex(tileOrigin, channelName)].resetActive(); } + throw; } }; @@ -902,8 +904,24 @@ void ImageGadget::updateTiles() // OK to capture `this` via raw pointer, because ~ImageGadget waits for // the background process to complete. [ this, channelsToCompute, dataWindow, tileFunctor ] { - ImageAlgo::parallelProcessTiles( m_image.get(), tileFunctor, dataWindow ); - m_dirtyFlags &= ~TilesDirty; + + try + { + ImageAlgo::parallelProcessTiles( m_image.get(), tileFunctor, dataWindow ); + m_dirtyFlags &= ~TilesDirty; + } + catch( const Gaffer::ProcessException & ) + { + // No point starting a new compute if it's just + // going to error again. + m_dirtyFlags &= ~TilesDirty; + } + catch( const IECore::Cancelled & ) + { + // Don't clear dirty flag, so that we restart + // on the next redraw. + } + if( refCount() ) { ImageGadgetPtr thisRef = this; @@ -913,6 +931,7 @@ void ImageGadget::updateTiles() } ); } + } );