Skip to content

Commit

Permalink
Add protect code
Browse files Browse the repository at this point in the history
  • Loading branch information
AdunFang committed Feb 25, 2025
1 parent 015ae0d commit cc08e98
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ internal static object GetInternalSizeProperty(BindableObject bindable)

var w = Interop.Actor.InternalGetPropertyFloat(view.SwigCPtr, Property.SizeWidth);
var h = Interop.Actor.InternalGetPropertyFloat(view.SwigCPtr, Property.SizeHeight);
var d = view.sizeDepth;
var d = Interop.Actor.InternalGetPropertyFloat(view.SwigCPtr, Property.SizeDepth);

view.internalSize.ResetValue(w, h, d);

Expand Down
2 changes: 0 additions & 2 deletions src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,8 @@ internal void SetSize(float width, float height)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}

private float sizeDepth = 0.0f;
internal void SetSize(float width, float height, float depth)
{
sizeDepth = depth;
Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
Expand Down
36 changes: 30 additions & 6 deletions src/Tizen.NUI/src/public/Common/Size.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,14 @@ public override int GetHashCode()
/// <since_tizen> 5 </since_tizen>
public bool EqualTo(Size rhs)
{
if (null != rhs && width == rhs.width && height == rhs.height && depth == rhs.depth)
if (null != rhs && NDalic.Equals(width, rhs.width) && NDalic.Equals(height, rhs.height) && NDalic.Equals(depth, rhs.depth))
{
return true;
}

return false;
else
{
return false;
}
}

/// <summary>
Expand All @@ -328,12 +330,14 @@ public bool EqualTo(Size rhs)
/// <since_tizen> 5 </since_tizen>
public bool NotEqualTo(Size rhs)
{
if (null != rhs && width == rhs.width && height == rhs.height && depth == rhs.depth)
if (null != rhs && NDalic.Equals(width, rhs.width) && NDalic.Equals(height, rhs.height) && NDalic.Equals(depth, rhs.depth))
{
return false;
}

return true;
else
{
return true;
}
}

/// <inheritdoc/>
Expand Down Expand Up @@ -397,16 +401,31 @@ protected override void Dispose(bool disposing)

private Size Add(Size rhs)
{
if (null == rhs)
{
throw new ArgumentNullException(nameof(rhs));
}

return new Size(width + rhs.width, height + rhs.height, depth + rhs.depth);
}

private Size Subtract(Size rhs)
{
if (null == rhs)
{
throw new ArgumentNullException(nameof(rhs));
}

return new Size(width - rhs.width, height - rhs.height, depth - rhs.depth);
}

private Size Multiply(Size rhs)
{
if (null == rhs)
{
throw new ArgumentNullException(nameof(rhs));
}

return new Size(width * rhs.width, height * rhs.height, depth * rhs.depth);
}

Expand All @@ -417,6 +436,11 @@ private Size Multiply(float rhs)

private Size Divide(Size rhs)
{
if (null == rhs)
{
throw new ArgumentNullException(nameof(rhs));
}

return new Size(width / rhs.width, height / rhs.height, depth / rhs.depth);
}

Expand Down

0 comments on commit cc08e98

Please sign in to comment.