[Tizen] Erase observer at TexturManager remove accepted/tizen/unified/20220830.133736 submit/tizen/20220830.074510
authorEverLEEst(SangHyeon Lee) <sh10233.lee@samsung.com>
Tue, 30 Aug 2022 06:27:19 +0000 (15:27 +0900)
committerEverLEEst(SangHyeon Lee) <sh10233.lee@samsung.com>
Tue, 30 Aug 2022 06:27:19 +0000 (15:27 +0900)
This reverts commit 03666bf124551fdf6afed6bbcba3cd998c776748.

automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
dali-toolkit/internal/texture-manager/texture-manager-impl.cpp

index 7a7bf26..01e0166 100644 (file)
@@ -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;
+}
index e23ee49..8d68a88 100644 (file)
@@ -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);
     }