From 8e3802536c6d31422a6ffc54b5ada8f33923c5a3 Mon Sep 17 00:00:00 2001 From: Eunki Hong Date: Thu, 4 Nov 2021 21:04:39 -0700 Subject: [PATCH] [Tizen] Let range for loop don't touch container at RenderManager Change-Id: Ia81f1bf25adc2840ef11ae0d8d944353cb977c51 Signed-off-by: Eunki Hong --- dali/internal/render/common/render-manager.cpp | 37 +++++++++++--------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index 5079c33..81d2582 100644 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -255,15 +255,13 @@ void RenderManager::RemoveTexture(Render::Texture* texture) { DALI_ASSERT_DEBUG(NULL != texture); - // Find the texture, use reference to pointer so we can do the erase safely - for(auto&& iter : mImpl->textureContainer) + // Find the texture, use std::find so we can do the erase safely + auto iter = std::find(mImpl->textureContainer.begin(), mImpl->textureContainer.end(), texture); + + if(iter != mImpl->textureContainer.end()) { - if(iter == texture) - { - texture->Destroy(); - mImpl->textureContainer.Erase(&iter); // Texture found; now destroy it - return; - } + texture->Destroy(); + mImpl->textureContainer.Erase(iter); // Texture found; now destroy it } } @@ -301,16 +299,13 @@ void RenderManager::RemoveFrameBuffer(Render::FrameBuffer* frameBuffer) { DALI_ASSERT_DEBUG(nullptr != frameBuffer); - // Find the sampler, use reference so we can safely do the erase - for(auto&& iter : mImpl->frameBufferContainer) - { - if(iter == frameBuffer) - { - frameBuffer->Destroy(); - mImpl->frameBufferContainer.Erase(&iter); // frameBuffer found; now destroy it + // Find the framebuffer, use std:find so we can safely do the erase + auto iter = std::find(mImpl->frameBufferContainer.begin(), mImpl->frameBufferContainer.end(), frameBuffer); - break; - } + if(iter != mImpl->frameBufferContainer.end()) + { + frameBuffer->Destroy(); + mImpl->frameBufferContainer.Erase(iter); // frameBuffer found; now destroy it } } @@ -381,13 +376,11 @@ void RenderManager::AddGeometry(OwnerPointer& geometry) void RenderManager::RemoveGeometry(Render::Geometry* geometry) { - auto it = std::find_if(mImpl->geometryContainer.begin(), mImpl->geometryContainer.end(), [geometry](auto& item) { - return geometry == item; - }); + auto iter = std::find(mImpl->geometryContainer.begin(), mImpl->geometryContainer.end(), geometry); - if(it != mImpl->geometryContainer.end()) + if(iter != mImpl->geometryContainer.end()) { - mImpl->geometryContainer.Erase(it); + mImpl->geometryContainer.Erase(iter); } } -- 2.7.4