Skip to content

Commit

Permalink
[NUI] Do not remove once event when we dispose
Browse files Browse the repository at this point in the history
Remove event from global static handler is heavy operation.

We can detach whether the view is disposed or not.
So just check disposed is more chip rather than remove event callback.

Signed-off-by: Eunki, Hong <[email protected]>
  • Loading branch information
Eunki, Hong authored and hinohie committed Mar 13, 2024
1 parent c67f934 commit 7983982
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
5 changes: 5 additions & 0 deletions src/Tizen.NUI/src/public/BaseComponents/AnimatedImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ public void SetValues()
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void UpdateImage()
{
if (Disposed)
{
return;
}

if (!imagePropertyUpdatedFlag) return;

// Assume that we are using standard Image at first.
Expand Down
16 changes: 6 additions & 10 deletions src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1447,11 +1447,6 @@ protected override void Dispose(DisposeTypes type)
borderSelector?.Reset(this);
resourceUrlSelector?.Reset(this);
imagePropertyUpdatedFlag = false;
if (imagePropertyUpdateProcessAttachedFlag)
{
ProcessorController.Instance.ProcessorOnceEvent -= UpdateImage;
imagePropertyUpdateProcessAttachedFlag = false;
}
cachedImagePropertyMap?.Dispose();
cachedImagePropertyMap = null;
}
Expand Down Expand Up @@ -1540,11 +1535,7 @@ private void RemoveImage()

// Image visual is not exist anymore. We should ignore lazy UpdateImage
imagePropertyUpdatedFlag = false;
if (imagePropertyUpdateProcessAttachedFlag)
{
ProcessorController.Instance.ProcessorOnceEvent -= UpdateImage;
imagePropertyUpdateProcessAttachedFlag = false;
}

// Update resourceUrl as empty value
_resourceUrl = "";
cachedImagePropertyMap[ImageVisualProperty.URL] = emptyValue;
Expand Down Expand Up @@ -1670,6 +1661,11 @@ private void UpdateImage(object source, EventArgs e)
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void UpdateImage()
{
if (Disposed)
{
return;
}

if (!imagePropertyUpdatedFlag) return;

imagePropertyUpdatedFlag = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,11 @@ private void CleanCallbackDictionaries()
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void UpdateImage()
{
if (Disposed)
{
return;
}

if (!imagePropertyUpdatedFlag) return;

// Update currentStates properties to cachedImagePropertyMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,6 @@ public partial class View

// Background extra data is not valid anymore. We should ignore lazy UpdateBackgroundExtraData
view.backgroundExtraDataUpdatedFlag = BackgroundExtraDataUpdatedFlag.None;
if (view.backgroundExtraDataUpdateProcessAttachedFlag)
{
ProcessorController.Instance.ProcessorOnceEvent -= view.UpdateBackgroundExtraData;
view.backgroundExtraDataUpdateProcessAttachedFlag = false;
}

propertyValue.Dispose();
propertyValue = null;
Expand Down
10 changes: 5 additions & 5 deletions src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,11 @@ private void UpdateBackgroundExtraData(object source, EventArgs e)
/// </summary>
internal virtual void UpdateBackgroundExtraData()
{
if (Disposed)
{
return;
}

if (backgroundExtraData == null)
{
return;
Expand Down Expand Up @@ -1457,11 +1462,6 @@ protected override void Dispose(DisposeTypes type)
}

backgroundExtraDataUpdatedFlag = BackgroundExtraDataUpdatedFlag.None;
if (backgroundExtraDataUpdateProcessAttachedFlag)
{
ProcessorController.Instance.ProcessorOnceEvent -= UpdateBackgroundExtraData;
backgroundExtraDataUpdateProcessAttachedFlag = false;
}

LayoutCount = 0;

Expand Down

0 comments on commit 7983982

Please sign in to comment.