From 0af19a453d91955d90cbb6ce1a997eb617a60aa8 Mon Sep 17 00:00:00 2001 From: zhouleonlei Date: Tue, 10 Nov 2020 10:52:38 +0800 Subject: [PATCH] [NUI] Fixed Svace issues --- .../Controls/DropDown.DropDownListBridge.cs | 4 ++ src/Tizen.NUI.Components/Controls/DropDown.cs | 4 ++ src/Tizen.NUI.Components/Controls/Pagination.cs | 11 +++-- .../RecyclerView/GridRecycleLayoutManager.cs | 38 ++++++++++------- .../RecyclerView/LinearRecycleLayoutManager.cs | 37 +++++++++------- .../Controls/RecyclerView/RecyclerView.cs | 12 ++++-- .../Controls/ScrollableBase.cs | 2 +- src/Tizen.NUI.Components/Utils/StyleManager.cs | 5 ++- .../src/internal/FishEyeLayoutManager.cs | 49 +++++++++++++++------- .../src/public/CircularPagination.cs | 14 +++---- src/Tizen.NUI.Wearable/src/public/WearableList.cs | 13 ++++++ src/Tizen.NUI/src/internal/BackKeyManager.cs | 22 +++++++--- src/Tizen.NUI/src/internal/EnumHelper.cs | 2 +- .../src/internal/Layouting/LayoutController.cs | 6 +-- src/Tizen.NUI/src/internal/PropertyRangeManager.cs | 2 +- src/Tizen.NUI/src/internal/WidgetApplication.cs | 7 +++- .../src/internal/XamlBinding/BindingExpression.cs | 2 +- .../src/internal/XamlBinding/MergedStyle.cs | 4 ++ src/Tizen.NUI/src/public/Layouting/FlexLayout.cs | 6 +++ src/Tizen.NUI/src/public/Layouting/LayoutItem.cs | 11 +++-- src/Tizen.NUI/src/public/NUIFrameComponent.cs | 2 +- 21 files changed, 174 insertions(+), 79 deletions(-) mode change 100644 => 100755 src/Tizen.NUI.Components/Controls/RecyclerView/GridRecycleLayoutManager.cs mode change 100644 => 100755 src/Tizen.NUI.Components/Controls/RecyclerView/LinearRecycleLayoutManager.cs mode change 100644 => 100755 src/Tizen.NUI.Components/Controls/RecyclerView/RecyclerView.cs mode change 100644 => 100755 src/Tizen.NUI.Wearable/src/internal/FishEyeLayoutManager.cs mode change 100644 => 100755 src/Tizen.NUI.Wearable/src/public/WearableList.cs mode change 100644 => 100755 src/Tizen.NUI/src/internal/BackKeyManager.cs diff --git a/src/Tizen.NUI.Components/Controls/DropDown.DropDownListBridge.cs b/src/Tizen.NUI.Components/Controls/DropDown.DropDownListBridge.cs index 0899013..d354209 100755 --- a/src/Tizen.NUI.Components/Controls/DropDown.DropDownListBridge.cs +++ b/src/Tizen.NUI.Components/Controls/DropDown.DropDownListBridge.cs @@ -100,6 +100,10 @@ namespace Tizen.NUI.Components return; } DropDownItemView listItemView = holder.ItemView as DropDownItemView; + if (listItemView == null) + { + return; + } listItemView.Name = "Item" + position; if (listItemData.Size != null) { diff --git a/src/Tizen.NUI.Components/Controls/DropDown.cs b/src/Tizen.NUI.Components/Controls/DropDown.cs index f336d19..ade1697 100755 --- a/src/Tizen.NUI.Components/Controls/DropDown.cs +++ b/src/Tizen.NUI.Components/Controls/DropDown.cs @@ -771,6 +771,10 @@ namespace Tizen.NUI.Components { PointStateType state = e.Touch.GetState(0); DropDownItemView touchedView = sender as DropDownItemView; + if (touchedView == null) + { + return true; + } touchedView.OnTouch(e.Touch); // Handle control state change diff --git a/src/Tizen.NUI.Components/Controls/Pagination.cs b/src/Tizen.NUI.Components/Controls/Pagination.cs index 0f6d5c5..6c863e4 100755 --- a/src/Tizen.NUI.Components/Controls/Pagination.cs +++ b/src/Tizen.NUI.Components/Controls/Pagination.cs @@ -157,8 +157,11 @@ namespace Tizen.NUI.Components } set { - paginationStyle.IndicatorSpacing = value; - UpdateVisual(); + if (paginationStyle != null) + { + paginationStyle.IndicatorSpacing = value; + UpdateVisual(); + } } } @@ -501,8 +504,8 @@ namespace Tizen.NUI.Components private void UpdateVisual() { - if (null == paginationStyle.IndicatorSize) return; - if (null == paginationStyle.IndicatorImageUrl) return; + if (null == paginationStyle?.IndicatorSize) return; + if (null == paginationStyle?.IndicatorImageUrl) return; if (indicatorCount < 0) return; for (int i = 0; i < indicatorList.Count; i++) diff --git a/src/Tizen.NUI.Components/Controls/RecyclerView/GridRecycleLayoutManager.cs b/src/Tizen.NUI.Components/Controls/RecyclerView/GridRecycleLayoutManager.cs old mode 100644 new mode 100755 index abfa02d..b546abc --- a/src/Tizen.NUI.Components/Controls/RecyclerView/GridRecycleLayoutManager.cs +++ b/src/Tizen.NUI.Components/Controls/RecyclerView/GridRecycleLayoutManager.cs @@ -86,7 +86,10 @@ namespace Tizen.NUI.Components { bool result = false; View list = Container.GetParent() as View; - + if (list == null) + { + return result; + } Vector2 visibleArea = new Vector2(Math.Abs(scrollPosition), Math.Abs(scrollPosition) + (LayoutOrientation == Orientation.Vertical ? list.Size.Width : list.Size.Height) @@ -133,7 +136,7 @@ namespace Tizen.NUI.Components { RecycleItem item = Container.Children[i] as RecycleItem; - if (previousItem != null) + if (previousItem != null && item != null) { item.Position = LayoutOrientation == Orientation.Vertical ? new Position( @@ -204,10 +207,13 @@ namespace Tizen.NUI.Components for (int i = 0; i < itemInGroup; i++) { RecycleItem target = Container.Children[0] as RecycleItem; - target.DataIndex = target.DataIndex + Container.Children.Count; - target.SiblingOrder = Container.Children.Count - 1; + if (target != null) + { + target.DataIndex = target.DataIndex + Container.Children.Count; + target.SiblingOrder = Container.Children.Count - 1; - result.Add(target); + result.Add(target); + } } } } @@ -220,16 +226,18 @@ namespace Tizen.NUI.Components for (int i = 0; i < itemInGroup; i++) { RecycleItem prevFirstItem = Container.Children[itemInGroup] as RecycleItem; - RecycleItem target = Container.Children[Container.Children.Count - 1] as RecycleItem; - target.Position = new Position( - LayoutOrientation == Orientation.Vertical ? (prevFirstItem.Position.X - target.Size.Width) : prevFirstItem.Position.X, - LayoutOrientation == Orientation.Vertical ? prevFirstItem.Position.Y : (prevFirstItem.Position.Y - target.Size.Height) - ); - target.DataIndex = target.DataIndex - Container.Children.Count; - target.SiblingOrder = 0; - - result.Add(target); + if (prevFirstItem != null && target != null) + { + target.Position = new Position( + LayoutOrientation == Orientation.Vertical ? (prevFirstItem.Position.X - target.Size.Width) : prevFirstItem.Position.X, + LayoutOrientation == Orientation.Vertical ? prevFirstItem.Position.Y : (prevFirstItem.Position.Y - target.Size.Height) + ); + target.DataIndex = target.DataIndex - Container.Children.Count; + target.SiblingOrder = 0; + + result.Add(target); + } } } } @@ -284,7 +292,7 @@ namespace Tizen.NUI.Components if(targetSibling > -1 && targetSibling < Container.Children.Count) { RecycleItem candidate = Container.Children[targetSibling] as RecycleItem; - if(candidate.DataIndex >= 0 && candidate.DataIndex < DataCount) + if(candidate != null && candidate.DataIndex >= 0 && candidate.DataIndex < DataCount) { nextFocusedView = candidate; } diff --git a/src/Tizen.NUI.Components/Controls/RecyclerView/LinearRecycleLayoutManager.cs b/src/Tizen.NUI.Components/Controls/RecyclerView/LinearRecycleLayoutManager.cs old mode 100644 new mode 100755 index 1cb35b9..0c7627e --- a/src/Tizen.NUI.Components/Controls/RecyclerView/LinearRecycleLayoutManager.cs +++ b/src/Tizen.NUI.Components/Controls/RecyclerView/LinearRecycleLayoutManager.cs @@ -35,6 +35,10 @@ namespace Tizen.NUI.Components { bool result = false; View list = Container.GetParent() as View; + if (list == null) + { + return result; + } Vector2 visibleArea = new Vector2( Math.Abs(scrollPosition), Math.Abs(scrollPosition) + (LayoutOrientation == Orientation.Horizontal? @@ -71,7 +75,7 @@ namespace Tizen.NUI.Components { RecycleItem item = Container.Children[i] as RecycleItem; - if(previousItem != null) + if(previousItem != null && item != null) { item.Position = LayoutOrientation == Orientation.Horizontal? new Position( @@ -137,10 +141,13 @@ namespace Tizen.NUI.Components { // Too many item is in front!!! move first item to back!!!! RecycleItem target = Container.Children[0] as RecycleItem; - target.DataIndex = target.DataIndex + Container.Children.Count; - target.SiblingOrder = Container.Children.Count - 1; + if (target != null) + { + target.DataIndex = target.DataIndex + Container.Children.Count; + target.SiblingOrder = Container.Children.Count - 1; - result.Add(target); + result.Add(target); + } } } else @@ -148,16 +155,18 @@ namespace Tizen.NUI.Components if(lastVisibleItemIndex < Container.Children.Count - 3) { RecycleItem prevFirstItem = Container.Children[0] as RecycleItem; - RecycleItem target = Container.Children[Container.Children.Count - 1] as RecycleItem; - target.Position = new Position( - LayoutOrientation == Orientation.Horizontal ? (prevFirstItem.Position.X - target.Size.Width) : prevFirstItem.Position.X, - LayoutOrientation == Orientation.Horizontal ? prevFirstItem.Position.Y : (prevFirstItem.Position.Y - target.Size.Height) - ); - target.DataIndex = target.DataIndex - Container.Children.Count; - target.SiblingOrder = 0; - - result.Add(target); + if (prevFirstItem != null && target != null) + { + target.Position = new Position( + LayoutOrientation == Orientation.Horizontal ? (prevFirstItem.Position.X - target.Size.Width) : prevFirstItem.Position.X, + LayoutOrientation == Orientation.Horizontal ? prevFirstItem.Position.Y : (prevFirstItem.Position.Y - target.Size.Height) + ); + target.DataIndex = target.DataIndex - Container.Children.Count; + target.SiblingOrder = 0; + + result.Add(target); + } } } @@ -210,7 +219,7 @@ namespace Tizen.NUI.Components if(targetSibling > -1 && targetSibling < Container.Children.Count) { RecycleItem candidate = Container.Children[targetSibling] as RecycleItem; - if(candidate.DataIndex >= 0 && candidate.DataIndex < DataCount) + if(candidate != null && candidate.DataIndex >= 0 && candidate.DataIndex < DataCount) { nextFocusedView = candidate; } diff --git a/src/Tizen.NUI.Components/Controls/RecyclerView/RecyclerView.cs b/src/Tizen.NUI.Components/Controls/RecyclerView/RecyclerView.cs old mode 100644 new mode 100755 index cf4a989..2f3daab --- a/src/Tizen.NUI.Components/Controls/RecyclerView/RecyclerView.cs +++ b/src/Tizen.NUI.Components/Controls/RecyclerView/RecyclerView.cs @@ -272,7 +272,10 @@ namespace Tizen.NUI.Components else { // If this is not first focus, request next focus to LayoutManager - nextFocusedView = LayoutManager.RequestNextFocusableView(currentFocusedView, direction, loopEnabled); + if (LayoutManager != null) + { + nextFocusedView = LayoutManager.RequestNextFocusableView(currentFocusedView, direction, loopEnabled); + } } if (nextFocusedView) @@ -316,8 +319,11 @@ namespace Tizen.NUI.Components } focusedView = nextFocusedView; - prevFocusedDataIndex = (nextFocusedView as RecycleItem).DataIndex; - + if ((nextFocusedView as RecycleItem) != null) + { + prevFocusedDataIndex = (nextFocusedView as RecycleItem).DataIndex; + } + ScrollTo(targetPosition, true); } else diff --git a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs index dbbebf4..f2d8869 100755 --- a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs +++ b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs @@ -123,7 +123,7 @@ namespace Tizen.NUI.Components Direction scrollingDirection = Direction.Vertical; ScrollableBase scrollableBase = this.Owner as ScrollableBase; - if (scrollableBase) + if (scrollableBase != null) { scrollingDirection = scrollableBase.ScrollingDirection; } diff --git a/src/Tizen.NUI.Components/Utils/StyleManager.cs b/src/Tizen.NUI.Components/Utils/StyleManager.cs index 0e77746..d1ebc4e 100755 --- a/src/Tizen.NUI.Components/Utils/StyleManager.cs +++ b/src/Tizen.NUI.Components/Utils/StyleManager.cs @@ -169,7 +169,10 @@ namespace Tizen.NUI.Components return; } - ThemeMap[key].AddStyleWithoutClone(component.FullName, (Activator.CreateInstance(style) as StyleBase).GetViewStyle()); + if (Activator.CreateInstance(style) as StyleBase != null) + { + ThemeMap[key].AddStyleWithoutClone(component.FullName, (Activator.CreateInstance(style) as StyleBase).GetViewStyle()); + } } /// diff --git a/src/Tizen.NUI.Wearable/src/internal/FishEyeLayoutManager.cs b/src/Tizen.NUI.Wearable/src/internal/FishEyeLayoutManager.cs old mode 100644 new mode 100755 index 3d472ae..76e12a8 --- a/src/Tizen.NUI.Wearable/src/internal/FishEyeLayoutManager.cs +++ b/src/Tizen.NUI.Wearable/src/internal/FishEyeLayoutManager.cs @@ -75,6 +75,11 @@ namespace Tizen.NUI.Wearable public override void Layout(float scrollPosition) { RecycleItem centerItem = Container.Children[FocusedIndex] as RecycleItem; + if (centerItem == null) + { + return; + } + float centerItemPosition = LayoutOrientation == Orientation.Horizontal ? centerItem.Position.X : centerItem.Position.Y; Vector2 stepRange = new Vector2(-scrollPosition - StepSize + 1.0f, -scrollPosition + StepSize - 1.0f); @@ -106,6 +111,10 @@ namespace Tizen.NUI.Wearable for (int i = FocusedIndex - 1; i > -1; i--) { RecycleItem target = Container.Children[i] as RecycleItem; + if (target == null) + { + continue; + } float prevItemPosition = LayoutOrientation == Orientation.Horizontal ? prevItem.Position.X : prevItem.Position.Y; float prevItemSize = (LayoutOrientation == Orientation.Horizontal ? prevItem.Size.Width : prevItem.Size.Height); @@ -140,6 +149,10 @@ namespace Tizen.NUI.Wearable for (int i = FocusedIndex + 1; i < Container.Children.Count; i++) { RecycleItem target = Container.Children[i] as RecycleItem; + if (target == null) + { + continue; + } float prevItemPosition = LayoutOrientation == Orientation.Horizontal ? prevItem.Position.X : prevItem.Position.Y; float prevItemSize = (LayoutOrientation == Orientation.Horizontal ? prevItem.Size.Width : prevItem.Size.Height); @@ -194,30 +207,34 @@ namespace Tizen.NUI.Wearable if (!isBack && FocusedIndex < 6) { RecycleItem target = Container.Children[Container.Children.Count - 1] as RecycleItem; + if (target != null) + { + int previousSiblingOrder = target.SiblingOrder; + target.SiblingOrder = 0; + target.DataIndex = target.DataIndex - Container.Children.Count; + target.Position = new Position(0, Math.Abs(scrollPosition) - 360); + target.Scale = new Vector3(0, 0, 0); - int previousSiblingOrder = target.SiblingOrder; - target.SiblingOrder = 0; - target.DataIndex = target.DataIndex - Container.Children.Count; - target.Position = new Position(0, Math.Abs(scrollPosition) - 360); - target.Scale = new Vector3(0, 0, 0); - - result.Add(target); + result.Add(target); - FocusedIndex++; + FocusedIndex++; + } } else if (isBack && FocusedIndex > 8) { RecycleItem target = Container.Children[0] as RecycleItem; + if (target != null) + { + int previousSiblingOrder = target.SiblingOrder; + target.SiblingOrder = Container.Children.Count - 1; + target.DataIndex = target.DataIndex + Container.Children.Count; + target.Position = new Position(0, Math.Abs(scrollPosition) + 360); + target.Scale = new Vector3(0, 0, 0); - int previousSiblingOrder = target.SiblingOrder; - target.SiblingOrder = Container.Children.Count - 1; - target.DataIndex = target.DataIndex + Container.Children.Count; - target.Position = new Position(0, Math.Abs(scrollPosition) + 360); - target.Scale = new Vector3(0, 0, 0); - - result.Add(target); + result.Add(target); - FocusedIndex--; + FocusedIndex--; + } } PrevScrollPosition = scrollPosition; diff --git a/src/Tizen.NUI.Wearable/src/public/CircularPagination.cs b/src/Tizen.NUI.Wearable/src/public/CircularPagination.cs index 8d844c6..c7217fa 100755 --- a/src/Tizen.NUI.Wearable/src/public/CircularPagination.cs +++ b/src/Tizen.NUI.Wearable/src/public/CircularPagination.cs @@ -530,11 +530,11 @@ namespace Tizen.NUI.Wearable if (!(selectOutIndicator is ImageVisual visual)) return; if (isCurrentIndicatorCentered) { - visual.URL = circularPaginationStyle.CenterIndicatorImageURL.Normal; + visual.URL = circularPaginationStyle?.CenterIndicatorImageURL?.Normal; } else { - visual.URL = circularPaginationStyle.IndicatorImageURL.Normal; + visual.URL = circularPaginationStyle?.IndicatorImageURL?.Normal; } visual.Opacity = 0.5f; } @@ -551,11 +551,11 @@ namespace Tizen.NUI.Wearable if (!(selectInIndicator is ImageVisual visual)) return; if (isCurrentIndicatorCentered) { - visual.URL = circularPaginationStyle.CenterIndicatorImageURL.Selected; + visual.URL = circularPaginationStyle?.CenterIndicatorImageURL?.Selected; } else { - visual.URL = circularPaginationStyle.IndicatorImageURL.Selected; + visual.URL = circularPaginationStyle?.IndicatorImageURL?.Selected; } visual.Opacity = 1.0f; } @@ -629,14 +629,14 @@ namespace Tizen.NUI.Wearable // The parameter, index, is for the index of either oddArray or evenArray. private void CreateIndicator(int index) { - if (circularPaginationStyle == null) + if (circularPaginationStyle == null || circularPaginationStyle.IndicatorSize == null) { return; } ImageVisual indicator = new ImageVisual { - URL = circularPaginationStyle.IndicatorImageURL.Normal, + URL = circularPaginationStyle.IndicatorImageURL?.Normal, Size = new Size2D((int)circularPaginationStyle.IndicatorSize.Width, (int)circularPaginationStyle.IndicatorSize.Height), Opacity = 0.5f, }; @@ -670,7 +670,7 @@ namespace Tizen.NUI.Wearable private void UpdateContainer() { - if (circularPaginationStyle == null) + if (circularPaginationStyle == null || circularPaginationStyle.IndicatorSize == null || container == null) { return; } diff --git a/src/Tizen.NUI.Wearable/src/public/WearableList.cs b/src/Tizen.NUI.Wearable/src/public/WearableList.cs old mode 100644 new mode 100755 index a993e0b..a7f4c32 --- a/src/Tizen.NUI.Wearable/src/public/WearableList.cs +++ b/src/Tizen.NUI.Wearable/src/public/WearableList.cs @@ -95,6 +95,11 @@ namespace Tizen.NUI.Wearable /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API public void SetFocus(int dataIndex, bool animated) { + if (LayoutManager == null) + { + return; + } + foreach (RecycleItem item in Children) { if (item.DataIndex == dataIndex) @@ -121,11 +126,19 @@ namespace Tizen.NUI.Wearable /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API protected override void OnPreReachedTargetPosition(float targetPosition) { + if (LayoutManager == null) + { + return; + } int targetDataIndex = (int)Math.Round(Math.Abs(targetPosition) / LayoutManager.StepSize); for (int i = 0; i < Children.Count; i++) { RecycleItem item = Children[i] as RecycleItem; + if (item == null) + { + continue; + } if (targetDataIndex == item.DataIndex) { diff --git a/src/Tizen.NUI/src/internal/BackKeyManager.cs b/src/Tizen.NUI/src/internal/BackKeyManager.cs old mode 100644 new mode 100755 index 1c27c9a..8633678 --- a/src/Tizen.NUI/src/internal/BackKeyManager.cs +++ b/src/Tizen.NUI/src/internal/BackKeyManager.cs @@ -76,13 +76,19 @@ namespace Tizen.NUI { // parent1 is in DefaultLayer. Layer comparison2AsLayer = comparison2 as Layer; - result = comparison2AsLayer.Depth > NUIApplication.GetDefaultWindow().GetDefaultLayer().Depth; + if(comparison2AsLayer != null) + { + result = comparison2AsLayer.Depth > NUIApplication.GetDefaultWindow().GetDefaultLayer().Depth; + } } else { // parent2 is in DefaultLayer. Layer comparison1AsLayer = comparison1 as Layer; - result = NUIApplication.GetDefaultWindow().GetDefaultLayer().Depth < comparison1AsLayer.Depth; + if (comparison1AsLayer != null) + { + result = NUIApplication.GetDefaultWindow().GetDefaultLayer().Depth < comparison1AsLayer.Depth; + } } } else @@ -97,8 +103,10 @@ namespace Tizen.NUI // Compare Depth Layer comparison1AsLayer = comparison1 as Layer; Layer comparison2AsLayer = comparison2 as Layer; - - result = comparison1AsLayer.Depth < comparison2AsLayer.Depth; + if (comparison1AsLayer != null && comparison2AsLayer != null) + { + result = comparison1AsLayer.Depth < comparison2AsLayer.Depth; + } } else { @@ -106,8 +114,10 @@ namespace Tizen.NUI // Compare SiblingOrder View comparison1AsView = comparison1 as View; View comparison2AsView = comparison2 as View; - - result = comparison1AsView.SiblingOrder < comparison2AsView.SiblingOrder; + if (comparison1AsView != null && comparison2AsView != null) + { + result = comparison1AsView.SiblingOrder < comparison2AsView.SiblingOrder; + } } } else diff --git a/src/Tizen.NUI/src/internal/EnumHelper.cs b/src/Tizen.NUI/src/internal/EnumHelper.cs index a4f2684..67fea42 100755 --- a/src/Tizen.NUI/src/internal/EnumHelper.cs +++ b/src/Tizen.NUI/src/internal/EnumHelper.cs @@ -38,7 +38,7 @@ namespace Tizen.NUI string result = value.ToString(); FieldInfo info = typeof(T).GetField(result); var attributes = info.GetCustomAttributes(typeof(DescriptionAttribute), true); - if (null != attributes?.FirstOrDefault()) + if (null != attributes?.FirstOrDefault() && (attributes.First() as DescriptionAttribute) != null) { result = (attributes.First() as DescriptionAttribute).Description; } diff --git a/src/Tizen.NUI/src/internal/Layouting/LayoutController.cs b/src/Tizen.NUI/src/internal/Layouting/LayoutController.cs index 269d4af..06fde1c 100755 --- a/src/Tizen.NUI/src/internal/Layouting/LayoutController.cs +++ b/src/Tizen.NUI/src/internal/Layouting/LayoutController.cs @@ -81,7 +81,7 @@ namespace Tizen.NUI if (layoutParent != null) { LayoutGroup layoutGroup = layoutParent as LayoutGroup; - if(! layoutGroup.LayoutRequested) + if(layoutGroup != null && !layoutGroup.LayoutRequested) { layoutGroup.RequestLayout(); } @@ -184,7 +184,7 @@ namespace Tizen.NUI Size2D rootSize; Position2D rootPosition = root.Position2D; View parentView = parentNode as View; - if (parentView) + if (parentView != null) { // Get parent View's Size. If using Legacy size negotiation then should have been set already. rootSize = new Size2D(parentView.Size2D.Width, parentView.Size2D.Height); @@ -263,7 +263,7 @@ namespace Tizen.NUI for (uint layerIndex = 0; layerIndex < numberOfLayers; layerIndex++) { Layer layer = _window.GetLayer(layerIndex); - if (layer) + if (layer != null) { for (uint i = 0; i < layer.ChildCount; i++) { diff --git a/src/Tizen.NUI/src/internal/PropertyRangeManager.cs b/src/Tizen.NUI/src/internal/PropertyRangeManager.cs index 42be51c..894727d 100755 --- a/src/Tizen.NUI/src/internal/PropertyRangeManager.cs +++ b/src/Tizen.NUI/src/internal/PropertyRangeManager.cs @@ -92,7 +92,7 @@ namespace Tizen.NUI // we add 1000, just incase View class starts using animatable properties int startAnimatablePropertyIndex = (int)Tizen.NUI.PropertyRanges.ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + maxCountPerDerivation; - while (viewType.GetTypeInfo().BaseType.Name != "CustomView") // custom view is our C# view base class. we don't go any deeper. + while (viewType.GetTypeInfo().BaseType?.Name != "CustomView") // custom view is our C# view base class. we don't go any deeper. { // for every base class increase property start index startEventPropertyIndex += (int)Tizen.NUI.PropertyRanges.DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION; // DALi uses 10,000 diff --git a/src/Tizen.NUI/src/internal/WidgetApplication.cs b/src/Tizen.NUI/src/internal/WidgetApplication.cs index 680602f..870caa8 100755 --- a/src/Tizen.NUI/src/internal/WidgetApplication.cs +++ b/src/Tizen.NUI/src/internal/WidgetApplication.cs @@ -122,6 +122,11 @@ namespace Tizen.NUI public static System.IntPtr WidgetCreateFunction(ref string widgetName) { + if ((Instance as WidgetApplication) == null) + { + return IntPtr.Zero; + } + Dictionary widgetInfo = (Instance as WidgetApplication).WidgetInfo; foreach (System.Type widgetType in widgetInfo.Keys) @@ -129,7 +134,7 @@ namespace Tizen.NUI if (widgetInfo[widgetType] == widgetName) { Widget widget = Activator.CreateInstance(widgetType) as Widget; - if (widget) + if (widget != null) { return widget.GetIntPtr(); } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/BindingExpression.cs b/src/Tizen.NUI/src/internal/XamlBinding/BindingExpression.cs index ca83712..895c0c3 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/BindingExpression.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/BindingExpression.cs @@ -304,7 +304,7 @@ namespace Tizen.NUI.Binding #endif if (property == null) //is the indexer defined on the base class? - property = sourceType.BaseType.GetProperty(indexerName); + property = sourceType.BaseType?.GetProperty(indexerName); if (property == null) //is the indexer defined on implemented interface ? { foreach (var implementedInterface in sourceType.ImplementedInterfaces) diff --git a/src/Tizen.NUI/src/internal/XamlBinding/MergedStyle.cs b/src/Tizen.NUI/src/internal/XamlBinding/MergedStyle.cs index 69d92a5..7c2469b 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/MergedStyle.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/MergedStyle.cs @@ -125,6 +125,10 @@ namespace Tizen.NUI.Binding void RegisterImplicitStyles() { Type type = TargetType; + if (type == null) + { + return; + } while (true) { BindableProperty implicitStyleProperty = BindableProperty.Create(nameof(ImplicitStyle), typeof(Style), typeof(View), default(Style), propertyChanged: (bindable, oldvalue, newvalue) => OnImplicitStyleChanged()); diff --git a/src/Tizen.NUI/src/public/Layouting/FlexLayout.cs b/src/Tizen.NUI/src/public/Layouting/FlexLayout.cs index d043366..b3ccc94 100755 --- a/src/Tizen.NUI/src/public/Layouting/FlexLayout.cs +++ b/src/Tizen.NUI/src/public/Layouting/FlexLayout.cs @@ -569,6 +569,12 @@ namespace Tizen.NUI { // We need to measure child layout View child = Registry.GetManagedBaseHandleFromNativePtr(childPtr) as View; + if (child == null) + { + measureSize.width = 0; + measureSize.height = 0; + return; + } LayoutItem childLayout = child.Layout; diff --git a/src/Tizen.NUI/src/public/Layouting/LayoutItem.cs b/src/Tizen.NUI/src/public/Layouting/LayoutItem.cs index 7470bce..17aa496 100755 --- a/src/Tizen.NUI/src/public/Layouting/LayoutItem.cs +++ b/src/Tizen.NUI/src/public/Layouting/LayoutItem.cs @@ -309,7 +309,7 @@ namespace Tizen.NUI if (Parent != null) { LayoutGroup layoutGroup = Parent as LayoutGroup; - if(! layoutGroup.LayoutRequested) + if(layoutGroup != null && !layoutGroup.LayoutRequested) { layoutGroup.RequestLayout(); } @@ -558,10 +558,13 @@ namespace Tizen.NUI } else { - Owner.SetSize(right - left, bottom - top, Owner.Position.Z); - if(SetPositionByLayout) + if (Owner.Position != null) { - Owner.SetPosition(left, top, Owner.Position.Z); + Owner.SetSize(right - left, bottom - top, Owner.Position.Z); + if (SetPositionByLayout) + { + Owner.SetPosition(left, top, Owner.Position.Z); + } } } diff --git a/src/Tizen.NUI/src/public/NUIFrameComponent.cs b/src/Tizen.NUI/src/public/NUIFrameComponent.cs index e9d577b..9de0008 100755 --- a/src/Tizen.NUI/src/public/NUIFrameComponent.cs +++ b/src/Tizen.NUI/src/public/NUIFrameComponent.cs @@ -37,7 +37,7 @@ namespace Tizen.NUI public override IWindowInfo CreateWindowInfo() { ComponentApplication instance = ComponentApplication.Instance as ComponentApplication; - if (instance) + if (instance != null) { if (!defaultWindowSet) { -- 2.7.4