From ca5adfbceeb163ac3a3957c0717f342b7526b03a Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Tue, 16 Aug 2022 13:28:23 +0900 Subject: [PATCH] [Tizen] Erase observer at TexturManager remove First, load one image from imageView. And while the first loaded image is removed from the scene, there is a problem if another image view loads with the same image URL. This is because there are cases where a callback is received from an invalid imageView by a previous observer. To prevent this problem, change the observer to also delete the texture when deleting it. Change-Id: Ied8235c35ff9772b36f55de3c3b5b21fbc4bce5c Signed-off-by: Eunki, Hong --- .../src/dali-toolkit/utc-Dali-ImageView.cpp | 23 ++++++++++++++++++++++ .../texture-manager/texture-manager-impl.cpp | 20 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp index 7a7bf26..01e0166 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp @@ -82,6 +82,8 @@ const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif"; const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg"; const char* TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json"; +const char* TEST_WEBP_FILE_NAME = TEST_RESOURCE_DIR "/dali-logo.webp"; + void TestUrl(ImageView imageView, const std::string url) { Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image")); @@ -3887,3 +3889,24 @@ int UtcDaliImageViewSetImageOnResourceReadySignal05(void) END_TEST; } + +int UtcDaliImageViewUseSameUrlWithAnimatedImageVisual(void) +{ + tet_infoline("Test multiple views with same image in animated image visual"); + ToolkitTestApplication application; + + gImageView1 = ImageView::New(TEST_WEBP_FILE_NAME); + application.GetScene().Add(gImageView1); + + tet_infoline("Remove imageView and Create new imageView with same url"); + application.GetScene().Remove(gImageView1); + gImageView2 = ImageView::New(TEST_WEBP_FILE_NAME); + application.GetScene().Add(gImageView2); + + application.SendNotification(); + application.Render(); + + tet_infoline("Check the ImageView load image successfully"); + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + END_TEST; +} diff --git a/dali-toolkit/internal/texture-manager/texture-manager-impl.cpp b/dali-toolkit/internal/texture-manager/texture-manager-impl.cpp index e23ee49..8d68a88 100644 --- a/dali-toolkit/internal/texture-manager/texture-manager-impl.cpp +++ b/dali-toolkit/internal/texture-manager/texture-manager-impl.cpp @@ -732,6 +732,26 @@ void TextureManager::Remove(const TextureManager::TextureId& textureId, TextureU } else { + // Erase observer + if(observer) + { + TextureCacheIndex textureInfoIndex = mTextureCacheManager.GetCacheIndexFromId(textureId); + if(textureInfoIndex != INVALID_CACHE_INDEX) + { + TextureInfo& textureInfo(mTextureCacheManager[textureInfoIndex]); + for(auto it = textureInfo.observerList.Begin(), endIt = textureInfo.observerList.End(); it != endIt; it++) + { + if((*it) == observer) + { + // Disconnect and remove the observer. + observer->DestructionSignal().Disconnect(this, &TextureManager::ObserverDestroyed); + textureInfo.observerList.Erase(it); + break; + } + } + } + } + // Remove textureId in CacheManager. mTextureCacheManager.RemoveCache(textureId); } -- 2.7.4