[NUI.Components] Guard more cases when Container disposed
authorEunki Hong <eunkiki.hong@samsung.com>
Wed, 21 Feb 2024 16:35:56 +0000 (01:35 +0900)
committerSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Tue, 27 Feb 2024 08:13:01 +0000 (17:13 +0900)
It might be possible if Container is disposed before ScrollBase disposed.

If then, Several logics breakdown.

Note : Since ScrollBase is time critical logics. So it is heavy to ensure the Container exist
at every Container usage.

Instead, let we just check Container is null at `OnScrollAnimationEnded` only,
which user can call immediatly by `Dispose()` API.

Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
src/Tizen.NUI.Components/Controls/ScrollableBase.cs

index b2cecd8..e83a1bf 100755 (executable)
@@ -1205,7 +1205,7 @@ namespace Tizen.NUI.Components
             scrolling = false;
             this.InterceptTouchEvent -= OnInterruptTouchingChildTouched;
 
-            ScrollEventArgs eventArgs = new ScrollEventArgs(ContentContainer.CurrentPosition);
+            ScrollEventArgs eventArgs = new ScrollEventArgs((ContentContainer != null) ? ContentContainer.CurrentPosition : Position.Zero);
             ScrollAnimationEnded?.Invoke(this, eventArgs);
             EmitScrollFinishedEvent();
 
@@ -1388,9 +1388,9 @@ namespace Tizen.NUI.Components
                 mPanGestureDetector?.Dispose();
                 mPanGestureDetector = null;
 
-                if(!(ContentContainer?.Disposed ?? true) && propertyNotification != null)
+                if(ContentContainer != null && propertyNotification != null)
                 {
-                    ContentContainer?.RemovePropertyNotification(propertyNotification);
+                    ContentContainer.RemovePropertyNotification(propertyNotification);
                 }
                 propertyNotification?.Dispose();
                 propertyNotification = null;
@@ -1398,10 +1398,6 @@ namespace Tizen.NUI.Components
 
             WheelEvent -= OnWheelEvent;
 
-            if (type == DisposeTypes.Explicit)
-            {
-
-            }
             base.Dispose(type);
         }