[NUI] Fix dispose timing error for ImageUrl
authorEunki Hong <eunkiki.hong@samsung.com>
Sun, 29 Jan 2023 08:03:44 +0000 (17:03 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Wed, 1 Feb 2023 07:07:33 +0000 (16:07 +0900)
Since we update ImageView lazy, ImageUrl's lifecycle might not matched
what user think.

```
ImageUrl imageUrl = ~~~.GenerateUrl();
ImageView imageView = new ImageView(imageUrl.ToString());
imageUrl.Dispose(); ///< We should allow this situation.
```

To make scene, We allow to call UpdateImage(); synchoronously
if we use GeneratedUrl().

Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/EncodedImageSample.cs

index 014ade7..295c04c 100755 (executable)
@@ -1297,6 +1297,11 @@ namespace Tizen.NUI.BaseComponents
                     {
                         UpdateImage(ImageVisualProperty.URL, setValue);
                     }
+                    // Special case. If we set GeneratedUrl, Create ImageVisual synchronously.
+                    if(value.StartsWith("dali://") || value.StartsWith("enbuf://"))
+                    {
+                        UpdateImage();
+                    }
                 }
             }
         }
index 4900772..45bc6ad 100755 (executable)
@@ -30,6 +30,9 @@ namespace Tizen.NUI.Samples
                 ResourceUrl = imageUrl?.ToString(),
             };
 
+            imageUrl?.Dispose();
+            buffer?.Dispose();
+
             win.GetDefaultLayer().Add(imageView);
         }