From dd3a90969cb0b8c62a7614ef97e8c3cfc98d161d Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 16 Sep 2024 10:00:49 -0400 Subject: [PATCH] Renderer : Avoid deprecated `shared_ptr::unique()` 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. --- src/GafferCycles/IECoreCyclesPreview/Renderer.cpp | 4 ++-- src/IECoreArnold/Renderer.cpp | 2 +- src/IECoreDelight/Renderer.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/GafferCycles/IECoreCyclesPreview/Renderer.cpp b/src/GafferCycles/IECoreCyclesPreview/Renderer.cpp index a94fed31d12..988e16a4ab6 100644 --- a/src/GafferCycles/IECoreCyclesPreview/Renderer.cpp +++ b/src/GafferCycles/IECoreCyclesPreview/Renderer.cpp @@ -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 @@ -1846,7 +1846,7 @@ class CameraCache : public IECore::RefCounted vector 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 diff --git a/src/IECoreArnold/Renderer.cpp b/src/IECoreArnold/Renderer.cpp index 1cd939d19c6..7c24dee9c97 100644 --- a/src/IECoreArnold/Renderer.cpp +++ b/src/IECoreArnold/Renderer.cpp @@ -2276,7 +2276,7 @@ class InstanceCache : public IECore::RefCounted vector 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 diff --git a/src/IECoreDelight/Renderer.cpp b/src/IECoreDelight/Renderer.cpp index bc5cb596c96..5456b8ca2e7 100644 --- a/src/IECoreDelight/Renderer.cpp +++ b/src/IECoreDelight/Renderer.cpp @@ -970,7 +970,7 @@ class InstanceCache : public IECore::RefCounted vector 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