Skip to content

Commit

Permalink
ImageGadget : Fix active not being reset when reverting to stored tile
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldresser committed Nov 18, 2020
1 parent 5686dbf commit 94dee0b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Fixes
- Spreadsheet : Fixed serialisation of default values which do not match those of the default row.
- Checkerboard : Checker colors are now exactly equal to the colorA and colorB parameters. Previously, there were very tiny floating point errors which grew larger as the distance from origin increased.
- Transform2DPlug : Fixed serialisation of dynamic plugs, such as plugs promoted to a Box.
- Image Viewer : Fix active tile indicators getting stuck when switching back to cached value partway through compute

API
---
Expand Down
2 changes: 2 additions & 0 deletions include/GafferImageUI/ImageGadget.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ class GAFFERIMAGEUI_API ImageGadget : public GafferUI::Gadget
// Called from the UI thread.
const IECoreGL::Texture *texture( bool &active );

void finishedUpdate();

private :

IECore::MurmurHash m_channelDataHash;
Expand Down
52 changes: 35 additions & 17 deletions src/GafferImageUI/ImageGadget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,11 @@ void ImageGadget::Tile::applyUpdates( const std::vector<Update> &updates )
}
}

void ImageGadget::Tile::finishedUpdate()
{
m_active = false;
}

const IECoreGL::Texture *ImageGadget::Tile::texture( bool &active )
{
const auto now = std::chrono::steady_clock::now();
Expand Down Expand Up @@ -1069,27 +1074,40 @@ void ImageGadget::updateTiles()

auto tileFunctor = [this, channelsToCompute] ( const ImagePlug *image, const V2i &tileOrigin ) {

vector<Tile::Update> updates;
ImagePlug::ChannelDataScope channelScope( Context::current() );
for( auto &channelName : channelsToCompute )
try
{
channelScope.setChannelName( channelName );
Tile &tile = m_tiles[TileIndex(tileOrigin, channelName)];
updates.push_back( tile.computeUpdate( image ) );
}

Tile::applyUpdates( updates );
vector<Tile::Update> updates;
ImagePlug::ChannelDataScope channelScope( Context::current() );
for( auto &channelName : channelsToCompute )
{
channelScope.setChannelName( channelName );
Tile &tile = m_tiles[TileIndex(tileOrigin, channelName)];
updates.push_back( tile.computeUpdate( image ) );
}

Tile::applyUpdates( updates );

if( refCount() && !m_renderRequestPending.exchange( true ) )
if( refCount() && !m_renderRequestPending.exchange( true ) )
{
// Must hold a reference to stop us dying before our UI thread call is scheduled.
ImageGadgetPtr thisRef = this;
ParallelAlgo::callOnUIThread(
[thisRef] {
thisRef->m_renderRequestPending = false;
thisRef->Gadget::dirty( DirtyType::Render );
}
);
}
}
catch (...)
{
// Must hold a reference to stop us dying before our UI thread call is scheduled.
ImageGadgetPtr thisRef = this;
ParallelAlgo::callOnUIThread(
[thisRef] {
thisRef->m_renderRequestPending = false;
thisRef->Gadget::dirty( DirtyType::Render );
}
);
// Make sure we don't leave behind active indicators if the computation is cancelled
for( auto &channelName : channelsToCompute )
{
m_tiles[TileIndex(tileOrigin, channelName)].finishedUpdate();
}
throw;
}
};

Expand Down

0 comments on commit 94dee0b

Please sign in to comment.