Skip to content

Commit

Permalink
[NUI] Fix dictionary variables to support non UsingXaml case
Browse files Browse the repository at this point in the history
In some codes, dictionary variables' getter does not check if the key
exists in the dictionary.
This causes an exception by accessing key's value which does not exist.

This PR resolves the above cases.
  • Loading branch information
Jaehyun-Cho authored and jaehyun0cho committed Feb 12, 2025
1 parent 2b6be80 commit af9b979
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 25 deletions.
45 changes: 40 additions & 5 deletions src/Tizen.NUI/src/public/Layouting/FlexLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,14 @@ public static AlignmentType GetFlexAlignmentSelf(View view)
}
else
{
return flexAlignmentSelfMap[view];
if (flexAlignmentSelfMap.TryGetValue(view, out var flexAlignmentSelf))
{
return flexAlignmentSelf;
}
else
{
return AlignmentType.Auto;
}
}
}

Expand Down Expand Up @@ -176,7 +183,14 @@ public static float GetFlexAspectRatio(View view)
}
else
{
return flexAspectRatioMap[view];
if (flexAspectRatioMap.TryGetValue(view, out var flexAspectRatio))
{
return flexAspectRatio;
}
else
{
return FlexUndefined;
}
}
}

Expand All @@ -196,7 +210,14 @@ public static float GetFlexBasis(View view)
}
else
{
return flexBasisMap[view];
if (flexBasisMap.TryGetValue(view, out var flexBasis))
{
return flexBasis;
}
else
{
return FlexUndefined;
}
}
}

Expand All @@ -216,7 +237,14 @@ public static float GetFlexShrink(View view)
}
else
{
return flexShrinkMap[view];
if (flexShrinkMap.TryGetValue(view, out var flexShrink))
{
return flexShrink;
}
else
{
return 1.0f;
}
}
}

Expand All @@ -236,7 +264,14 @@ public static float GetFlexGrow(View view)
}
else
{
return flexGrowMap[view];
if (flexGrowMap.TryGetValue(view, out var flexGrow))
{
return flexGrow;
}
else
{
return FlexUndefined;
}
}
}

Expand Down
72 changes: 64 additions & 8 deletions src/Tizen.NUI/src/public/Layouting/GridLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,14 @@ public static int GetColumn(View view)
}
else
{
return columnMap[view];
if (columnMap.TryGetValue(view, out var column))
{
return column;
}
else
{
return AutoColumn;
}
}
}

Expand All @@ -146,7 +153,14 @@ public static int GetColumnSpan(View view)
}
else
{
return columnSpanMap[view] != 0 ? columnSpanMap[view] : 1;
if (columnSpanMap.TryGetValue(view, out var columnSpan))
{
return columnSpan;
}
else
{
return 1;
}
}
}

Expand All @@ -165,7 +179,14 @@ public static int GetRow(View view)
}
else
{
return rowMap[view];
if (rowMap.TryGetValue(view, out var row))
{
return row;
}
else
{
return AutoRow;
}
}
}

Expand All @@ -184,7 +205,14 @@ public static int GetRowSpan(View view)
}
else
{
return rowSpanMap[view] != 0 ? rowSpanMap[view] : 1;
if (rowSpanMap.TryGetValue(view, out var rowSpan))
{
return rowSpan;
}
else
{
return 1;
}
}
}

Expand All @@ -203,7 +231,14 @@ public static StretchFlags GetHorizontalStretch(View view)
}
else
{
return horizontalStretchMap[view];
if (horizontalStretchMap.TryGetValue(view, out var horizontalStretch))
{
return horizontalStretch;
}
else
{
return StretchFlags.None;
}
}
}

Expand All @@ -222,7 +257,14 @@ public static StretchFlags GetVerticalStretch(View view)
}
else
{
return verticalStretchMap[view];
if (verticalStretchMap.TryGetValue(view, out var verticalStretch))
{
return verticalStretch;
}
else
{
return StretchFlags.None;
}
}
}

Expand All @@ -241,7 +283,14 @@ public static Alignment GetHorizontalAlignment(View view)
}
else
{
return horizontalAlignmentMap[view];
if (horizontalAlignmentMap.TryGetValue(view, out var horizontalAlignment))
{
return horizontalAlignment;
}
else
{
return Alignment.Start;
}
}
}

Expand All @@ -260,7 +309,14 @@ public static Alignment GetVerticalAlignment(View view)
}
else
{
return verticalAlignmentMap[view];
if (verticalAlignmentMap.TryGetValue(view, out var verticalAlignment))
{
return verticalAlignment;
}
else
{
return Alignment.Start;
}
}
}

Expand Down
108 changes: 96 additions & 12 deletions src/Tizen.NUI/src/public/Layouting/RelativeLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,14 @@ public static View GetLeftTarget(BindableObject view)
}
else
{
return leftTargetMap[(View)view];
if (leftTargetMap.TryGetValue((View)view, out var leftTarget))
{
return leftTarget;
}
else
{
return null;
}
}
}

Expand All @@ -188,7 +195,14 @@ public static View GetRightTarget(BindableObject view)
}
else
{
return rightTargetMap[(View)view];
if (rightTargetMap.TryGetValue((View)view, out var rightTarget))
{
return rightTarget;
}
else
{
return null;
}
}
}

Expand All @@ -208,7 +222,14 @@ public static View GetTopTarget(BindableObject view)
}
else
{
return topTargetMap[(View)view];
if (topTargetMap.TryGetValue((View)view, out var topTarget))
{
return topTarget;
}
else
{
return null;
}
}
}

Expand All @@ -228,7 +249,14 @@ public static View GetBottomTarget(BindableObject view)
}
else
{
return bottomTargetMap[(View)view];
if (bottomTargetMap.TryGetValue((View)view, out var bottomTarget))
{
return bottomTarget;
}
else
{
return null;
}
}
}

Expand All @@ -247,7 +275,14 @@ public static float GetLeftRelativeOffset(View view)
}
else
{
return leftRelativeOffsetMap[view];
if (leftRelativeOffsetMap.TryGetValue(view, out var leftRelativeOffset))
{
return leftRelativeOffset;
}
else
{
return 0.0f;
}
}
}

Expand All @@ -266,7 +301,14 @@ public static float GetRightRelativeOffset(View view)
}
else
{
return rightRelativeOffsetMap[view];
if (rightRelativeOffsetMap.TryGetValue(view, out var rightRelativeOffset))
{
return rightRelativeOffset;
}
else
{
return 1.0f;
}
}
}

Expand All @@ -285,7 +327,14 @@ public static float GetTopRelativeOffset(View view)
}
else
{
return topRelativeOffsetMap[view];
if (topRelativeOffsetMap.TryGetValue(view, out var topRelativeOffset))
{
return topRelativeOffset;
}
else
{
return 0.0f;
}
}
}

Expand All @@ -304,7 +353,14 @@ public static float GetBottomRelativeOffset(View view)
}
else
{
return bottomRelativeOffsetMap[view];
if (bottomRelativeOffsetMap.TryGetValue(view, out var bottomRelativeOffset))
{
return bottomRelativeOffset;
}
else
{
return 1.0f;
}
}
}

Expand All @@ -323,7 +379,14 @@ public static Alignment GetHorizontalAlignment(View view)
}
else
{
return horizontalAlignmentMap[view];
if (horizontalAlignmentMap.TryGetValue(view, out var horizontalAlignment))
{
return horizontalAlignment;
}
else
{
return Alignment.Start;
}
}
}

Expand All @@ -342,7 +405,14 @@ public static Alignment GetVerticalAlignment(View view)
}
else
{
return verticalAlignmentMap[view];
if (verticalAlignmentMap.TryGetValue(view, out var verticalAlignment))
{
return verticalAlignment;
}
else
{
return Alignment.Start;
}
}
}

Expand All @@ -361,7 +431,14 @@ public static bool GetFillHorizontal(View view)
}
else
{
return fillHorizontalMap[view];
if (fillHorizontalMap.TryGetValue(view, out var fillHorizontal))
{
return fillHorizontal;
}
else
{
return false;
}
}
}

Expand All @@ -380,7 +457,14 @@ public static bool GetFillVertical(View view)
}
else
{
return fillVerticalMap[view];
if (fillVerticalMap.TryGetValue(view, out var fillVertical))
{
return fillVertical;
}
else
{
return false;
}
}
}

Expand Down

0 comments on commit af9b979

Please sign in to comment.