diff --git a/RenderSystems/Direct3D11/src/OgreD3D11DeviceResource.cpp b/RenderSystems/Direct3D11/src/OgreD3D11DeviceResource.cpp index 730d3c7219..eaf7728c6b 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11DeviceResource.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11DeviceResource.cpp @@ -42,7 +42,7 @@ namespace Ogre } // ------------------------------------------------------------------------ - static D3D11DeviceResourceManager *gs_D3D11DeviceResourceManager = NULL; + static D3D11DeviceResourceManager *gs_D3D11DeviceResourceManager = nullptr; D3D11DeviceResourceManager *D3D11DeviceResourceManager::get() { @@ -51,7 +51,7 @@ namespace Ogre D3D11DeviceResourceManager::D3D11DeviceResourceManager() { - assert( gs_D3D11DeviceResourceManager == NULL ); + assert( gs_D3D11DeviceResourceManager == nullptr ); gs_D3D11DeviceResourceManager = this; } @@ -59,7 +59,7 @@ namespace Ogre { assert( mResources.empty() ); assert( gs_D3D11DeviceResourceManager == this ); - gs_D3D11DeviceResourceManager = NULL; + gs_D3D11DeviceResourceManager = nullptr; } void D3D11DeviceResourceManager::notifyResourceCreated( D3D11DeviceResource *deviceResource ) @@ -86,14 +86,10 @@ namespace Ogre assert( mResourcesCopy.empty() ); // reentrancy is not expected nor supported mResourcesCopy = mResources; - vector::type::iterator it = mResourcesCopy.begin(); - vector::type::iterator en = mResourcesCopy.end(); - while( it != en ) - { - if( D3D11DeviceResource *deviceResource = *it ) - deviceResource->notifyDeviceLost( device ); - ++it; - } + for( D3D11DeviceResource *deviceResource : mResourcesCopy ) + if( deviceResource != nullptr ) + deviceResource->notifyDeviceLost( device ); // notifyResourceDestroyed() can be called + mResourcesCopy.clear(); } @@ -101,17 +97,12 @@ namespace Ogre { assert( mResourcesCopy.empty() ); // reentrancy is not expected nor supported mResourcesCopy = mResources; + for( unsigned pass = 0; pass < 2; ++pass ) - { - vector::type::iterator it = mResourcesCopy.begin(); - vector::type::iterator en = mResourcesCopy.end(); - while( it != en ) - { - if( D3D11DeviceResource *deviceResource = *it ) - deviceResource->notifyDeviceRestored( device, pass ); - ++it; - } - } + for( D3D11DeviceResource *deviceResource : mResourcesCopy ) + if( deviceResource != nullptr ) + deviceResource->notifyDeviceRestored( device, pass ); // subresources created + mResourcesCopy.clear(); } diff --git a/RenderSystems/Vulkan/src/OgreVulkanDeviceResource.cpp b/RenderSystems/Vulkan/src/OgreVulkanDeviceResource.cpp index 2508f5953b..6bff28b4b4 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanDeviceResource.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanDeviceResource.cpp @@ -42,7 +42,7 @@ namespace Ogre } // ------------------------------------------------------------------------ - static VulkanDeviceResourceManager *gs_VulkanDeviceResourceManager = NULL; + static VulkanDeviceResourceManager *gs_VulkanDeviceResourceManager = nullptr; VulkanDeviceResourceManager *VulkanDeviceResourceManager::get() { @@ -51,7 +51,7 @@ namespace Ogre VulkanDeviceResourceManager::VulkanDeviceResourceManager() { - assert( gs_VulkanDeviceResourceManager == NULL ); + assert( gs_VulkanDeviceResourceManager == nullptr ); gs_VulkanDeviceResourceManager = this; } @@ -59,7 +59,7 @@ namespace Ogre { assert( mResources.empty() ); assert( gs_VulkanDeviceResourceManager == this ); - gs_VulkanDeviceResourceManager = NULL; + gs_VulkanDeviceResourceManager = nullptr; } void VulkanDeviceResourceManager::notifyResourceCreated( VulkanDeviceResource *deviceResource ) @@ -92,14 +92,10 @@ namespace Ogre assert( mResourcesCopy.empty() ); // reentrancy is not expected nor supported mResourcesCopy = mResources; - vector::type::iterator it = mResourcesCopy.begin(); - vector::type::iterator en = mResourcesCopy.end(); - while( it != en ) - { - if( VulkanDeviceResource *deviceResource = *it ) - deviceResource->notifyDeviceLost(); - ++it; - } + for( VulkanDeviceResource *deviceResource : mResourcesCopy ) + if( deviceResource != nullptr ) + deviceResource->notifyDeviceLost(); // notifyResourceDestroyed() can be called inside + mResourcesCopy.clear(); } @@ -109,17 +105,12 @@ namespace Ogre assert( mResourcesCopy.empty() ); // reentrancy is not expected nor supported mResourcesCopy = mResources; + for( unsigned pass = 0; pass < 2; ++pass ) - { - vector::type::iterator it = mResourcesCopy.begin(); - vector::type::iterator en = mResourcesCopy.end(); - while( it != en ) - { - if( VulkanDeviceResource *deviceResource = *it ) - deviceResource->notifyDeviceRestored( pass ); - ++it; - } - } + for( VulkanDeviceResource *deviceResource : mResourcesCopy ) + if( deviceResource != nullptr ) + deviceResource->notifyDeviceRestored( pass ); // subresources could be created + mResourcesCopy.clear(); }