Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageGadget : Fix active not being reset when reverting to stored tile #4011

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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