From adc32d064a8c8a38ca69da26a06bd2443305e590 Mon Sep 17 00:00:00 2001 From: huiyueun <35286162+huiyueun@users.noreply.github.com> Date: Thu, 21 Mar 2019 14:54:56 +0900 Subject: [PATCH] [NUI] Fix svace issue (#759) * [NUI] Fix VD Svace issue (#696) Signed-off-by: huiyu.eun * [NUI] Fix Svace issue (#727) Signed-off-by: huiyu.eun * [NUI] Fix svace issue (#735) Signed-off-by: huiyu.eun * Update XamlPropertyCondition.cs --- src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs | 2 +- src/Tizen.NUI/src/internal/Xaml/MarkupExtensionParser.cs | 6 +++--- .../XamlBinding/Interactivity/AttachedCollection.cs | 14 +++++++------- .../XamlBinding/Interactivity/XamlPropertyCondition.cs | 15 ++++++++++----- .../src/internal/XamlBinding/ObservableWrapper.cs | 2 +- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs index e3e40d8..a501ff2 100755 --- a/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs @@ -315,7 +315,7 @@ namespace Tizen.NUI.Xaml enode.SkipProperties.Add(name); var value = Context.Values[node]; var serviceProvider = new XamlServiceProvider(enode, Context); - var convertedValue = value.ConvertTo(parameter?.ParameterType, () => parameter, serviceProvider); + var convertedValue = value?.ConvertTo(parameter.ParameterType, () => parameter, serviceProvider); array[i] = convertedValue; } return array; diff --git a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensionParser.cs b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensionParser.cs index ec76d26..e36449e 100755 --- a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensionParser.cs +++ b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensionParser.cs @@ -64,14 +64,14 @@ namespace Tizen.NUI.Xaml prop = ApplyPropertiesVisitor.GetContentPropertyName(t.GetTypeInfo()); if (prop == null) return; - setter = t.GetRuntimeProperty(prop).SetMethod; + setter = t.GetRuntimeProperty(prop)?.SetMethod; } else - setter = markupExtension.GetType().GetRuntimeProperty(prop).SetMethod; + setter = markupExtension.GetType().GetRuntimeProperty(prop)?.SetMethod; if (value == null && strValue != null) { - value = strValue.ConvertTo(markupExtension.GetType().GetRuntimeProperty(prop).PropertyType, + value = strValue.ConvertTo(markupExtension.GetType().GetRuntimeProperty(prop)?.PropertyType, (Func)null, serviceProvider); } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/AttachedCollection.cs b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/AttachedCollection.cs index d5d1fc3..b1c5247 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/AttachedCollection.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/AttachedCollection.cs @@ -41,7 +41,7 @@ namespace Tizen.NUI.Binding var bindable = weakbindable.Target as BindableObject; if (bindable == null) continue; - item.DetachFrom(bindable); + item?.DetachFrom(bindable); } } base.ClearItems(); @@ -55,7 +55,7 @@ namespace Tizen.NUI.Binding var bindable = weakbindable.Target as BindableObject; if (bindable == null) continue; - item.AttachTo(bindable); + item?.AttachTo(bindable); } } @@ -66,13 +66,13 @@ namespace Tizen.NUI.Binding _associatedObjects.Add(new WeakReference(bindable)); } foreach (T item in this) - item.AttachTo(bindable); + item?.AttachTo(bindable); } protected virtual void OnDetachingFrom(BindableObject bindable) { foreach (T item in this) - item.DetachFrom(bindable); + item?.DetachFrom(bindable); lock (_associatedObjects) { for (var i = 0; i < _associatedObjects.Count; i++) @@ -96,7 +96,7 @@ namespace Tizen.NUI.Binding var bindable = weakbindable.Target as BindableObject; if (bindable == null) continue; - item.DetachFrom(bindable); + item?.DetachFrom(bindable); } base.RemoveItem(index); @@ -110,7 +110,7 @@ namespace Tizen.NUI.Binding var bindable = weakbindable.Target as BindableObject; if (bindable == null) continue; - old.DetachFrom(bindable); + old?.DetachFrom(bindable); } base.SetItem(index, item); @@ -120,7 +120,7 @@ namespace Tizen.NUI.Binding var bindable = weakbindable.Target as BindableObject; if (bindable == null) continue; - item.AttachTo(bindable); + item?.AttachTo(bindable); } } } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/XamlPropertyCondition.cs b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/XamlPropertyCondition.cs index adcc068..1f83d18 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/XamlPropertyCondition.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/XamlPropertyCondition.cs @@ -28,13 +28,14 @@ namespace Tizen.NUI.Binding return; if (IsSealed) throw new InvalidOperationException("Can not change Property once the Trigger has been applied."); + _property = value; //convert the value if (_property != null && s_valueConverter != null) { - Func minforetriever = () => Property.DeclaringType.GetRuntimeProperty(Property.PropertyName); - Value = s_valueConverter.Convert(Value, Property.ReturnType, minforetriever, null); + Func minforetriever = () => _property.DeclaringType.GetRuntimeProperty(_property.PropertyName); + Value = s_valueConverter.Convert(Value, _property.ReturnType, minforetriever, null); } } } @@ -52,10 +53,14 @@ namespace Tizen.NUI.Binding //convert the value if (_property != null && s_valueConverter != null) { - Func minforetriever = () => Property.DeclaringType.GetRuntimeProperty(Property.PropertyName); - value = s_valueConverter.Convert(value, Property.ReturnType, minforetriever, null); + Func minforetriever = () => _property.DeclaringType.GetRuntimeProperty(_property.PropertyName); + _triggerValue = s_valueConverter.Convert(value, _property.ReturnType, minforetriever, null); + } + else + { + _triggerValue = value; } - _triggerValue = value; + } } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/ObservableWrapper.cs b/src/Tizen.NUI/src/internal/XamlBinding/ObservableWrapper.cs index b897657..2a220ea 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/ObservableWrapper.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/ObservableWrapper.cs @@ -139,7 +139,7 @@ namespace Tizen.NUI.Binding throw new NotSupportedException("The collection is read-only"); int innerIndex = ToInnerIndex(index); TTrack item = _list[innerIndex]; - if (item.Owned) + if (item != null && item.Owned) { _list.RemoveAt(innerIndex); item.Owned = false; -- 2.7.4