From: Eunki Hong Date: Fri, 5 Nov 2021 04:04:39 +0000 (-0700) Subject: [Tizen] Let range for loop don't touch container at RenderManager X-Git-Tag: submit/tizen/20211109.063334~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e3802536c6d31422a6ffc54b5ada8f33923c5a3;p=platform%2Fcore%2Fuifw%2Fdali-core.git [Tizen] Let range for loop don't touch container at RenderManager Change-Id: Ia81f1bf25adc2840ef11ae0d8d944353cb977c51 Signed-off-by: Eunki Hong --- 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); } }