Skip to content

Commit

Permalink
The mutex try-lock for the destructor seems to go into an infinite lo…
Browse files Browse the repository at this point in the history
…op on Windows when de-selecting a shader (destructing a shaderball preview), removing it seems to not cause issues on Linux.
  • Loading branch information
boberfly committed Jan 12, 2020
1 parent 8c04717 commit 3fc5041
Showing 1 changed file with 16 additions and 28 deletions.
44 changes: 16 additions & 28 deletions src/GafferCycles/IECoreCyclesPreview/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2825,34 +2825,22 @@ class CyclesRenderer final : public IECoreScenePreview::Renderer
{
m_session->set_pause( true );

while( true )
{
if( m_scene->mutex.try_lock() )
{
// Reduce the refcount so that it gets cleared.
m_backgroundShader = nullptr;
m_cameraCache.reset();
m_lightCache.reset();
m_shaderCache.reset();
m_instanceCache.reset();
m_attributesCache.reset();
m_particleSystemsCache.reset();
// Gaffer has already deleted these, so we can't double-delete
m_scene->shaders.clear();
m_scene->meshes.clear();
m_scene->objects.clear();
m_scene->lights.clear();
m_scene->particle_systems.clear();
// Cycles created the defaultCamera, so we give it back for it to delete.
m_scene->camera = m_defaultCamera;
m_scene->mutex.unlock();
break;
}
else
{
std::this_thread::sleep_for( m_sceneLockInterval );
}
}
// Reduce the refcount so that it gets cleared.
m_backgroundShader = nullptr;
m_cameraCache.reset();
m_lightCache.reset();
m_shaderCache.reset();
m_instanceCache.reset();
m_attributesCache.reset();
m_particleSystemsCache.reset();
// Gaffer has already deleted these, so we can't double-delete
m_scene->shaders.clear();
m_scene->meshes.clear();
m_scene->objects.clear();
m_scene->lights.clear();
m_scene->particle_systems.clear();
// Cycles created the defaultCamera, so we give it back for it to delete.
m_scene->camera = m_defaultCamera;

delete m_session;
delete m_imageManagerOld;
Expand Down

0 comments on commit 3fc5041

Please sign in to comment.