Skip to content

Commit

Permalink
Renderer : Avoid deprecated shared_ptr::unique()
Browse files Browse the repository at this point in the history
This was deprecated in c++17 and removed in c++20 because it gives
potentially incorrect results in a multithreaded environment. All of
our uses are noted as not being able to be called by multiple threads,
so the comparison `use_count() == 1` is valid.
  • Loading branch information
ericmehl committed Sep 16, 2024
1 parent 6fd47d8 commit dd3a909
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/GafferCycles/IECoreCyclesPreview/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ class InstanceCache : public IECore::RefCounted

for( Geometry::iterator it = m_geometry.begin(), eIt = m_geometry.end(); it != eIt; ++it )
{
if( it->second.unique() )
if( it->second.use_count() == 1 )
{
// Only one reference - this is ours, so
// nothing outside of the cache is using the
Expand Down Expand Up @@ -1846,7 +1846,7 @@ class CameraCache : public IECore::RefCounted
vector<IECore::MurmurHash> toErase;
for( Cache::iterator it = m_cache.begin(), eIt = m_cache.end(); it != eIt; ++it )
{
if( it->second.unique() )
if( it->second.use_count() == 1 )
{
// Only one reference - this is ours, so
// nothing outside of the cache is using the
Expand Down
2 changes: 1 addition & 1 deletion src/IECoreArnold/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2276,7 +2276,7 @@ class InstanceCache : public IECore::RefCounted
vector<IECore::MurmurHash> toErase;
for( Cache::iterator it = m_cache.begin(), eIt = m_cache.end(); it != eIt; ++it )
{
if( it->second.unique() )
if( it->second.use_count() == 1 )
{
// Only one reference - this is ours, so
// nothing outside of the cache is using the
Expand Down
2 changes: 1 addition & 1 deletion src/IECoreDelight/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ class InstanceCache : public IECore::RefCounted
vector<IECore::MurmurHash> toErase;
for( Cache::iterator it = m_cache.begin(), eIt = m_cache.end(); it != eIt; ++it )
{
if( it->second.unique() )
if( it->second.use_count() == 1 )
{
// Only one reference - this is ours, so
// nothing outside of the cache is using the
Expand Down

0 comments on commit dd3a909

Please sign in to comment.