[NUI] Fix VD svace issue (#655)
authorhuiyueun <35286162+huiyueun@users.noreply.github.com>
Wed, 16 Jan 2019 06:25:00 +0000 (15:25 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 16 Jan 2019 06:25:00 +0000 (15:25 +0900)
- add null check
- add lock

Change-Id: I706d1b0314e1e9096597eedc01593932945286e1
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/Tizen.NUI/src/internal/Application.cs
src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs
src/Tizen.NUI/src/internal/XamlBinding/ObservableWrapper.cs
src/Tizen.NUI/src/internal/XamlBinding/Setter.cs
src/Tizen.NUI/src/internal/XamlBinding/StyleSheets/StyleSheetExtensions.cs
src/Tizen.NUI/src/public/BaseHandle.cs

index b6b777b..378758b 100755 (executable)
@@ -1320,11 +1320,14 @@ namespace Tizen.NUI
         // Callback for Application BatteryLowSignal
         private void OnNUIApplicationBatteryLow(BatteryStatus status)
         {
-            NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
+            lock (this)
+            {
+                NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
 
-            // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
-            e.BatteryStatus = status;
-            _applicationBatteryLowEventHandler?.Invoke(this, e);
+                // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
+                e.BatteryStatus = status;
+                _applicationBatteryLowEventHandler?.Invoke(this, e);
+            }
         }
 
         /**
@@ -1365,11 +1368,14 @@ namespace Tizen.NUI
         // Callback for Application MemoryLowSignal
         private void OnNUIApplicationMemoryLow(MemoryStatus status)
         {
-            NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
+            lock (this)
+            {
+                NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
 
-            // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
-            e.MemoryStatus = status;
-            _applicationMemoryLowEventHandler?.Invoke(this, e);
+                // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
+                e.MemoryStatus = status;
+                _applicationMemoryLowEventHandler?.Invoke(this, e);
+            }
         }
 
         /**
index c148a6b..e8d90eb 100755 (executable)
@@ -197,7 +197,7 @@ namespace Tizen.NUI.Xaml
                             ci.GetParameters().Length != 0 && ci.IsPublic &&
                             ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof (ParameterAttribute))));
             object[] arguments = CreateArgumentsArray(node, ctorInfo);
-            return ctorInfo.Invoke(arguments);
+            return ctorInfo?.Invoke(arguments);
         }
 
         public object CreateFromFactory(Type nodeType, IElementNode node)
@@ -283,7 +283,7 @@ namespace Tizen.NUI.Xaml
             {
                 var parameter = ctorInfo.GetParameters()[i];
                 var propname =
-                    parameter.CustomAttributes.First(attr => attr.AttributeType == typeof (ParameterAttribute))
+                    parameter?.CustomAttributes?.First(attr => attr.AttributeType == typeof (ParameterAttribute))?
                         .ConstructorArguments.First()
                         .Value as string;
                 var name = new XmlName("", propname);
index 8f9a3f5..dcf80ec 100755 (executable)
@@ -183,7 +183,7 @@ namespace Tizen.NUI.Binding
                     if (e.OldStartingIndex == -1 || e.OldItems?.Count > 1)
                         goto case NotifyCollectionChangedAction.Reset;
 
-                    var removedItem = e.OldItems[0] as TRestrict;
+                    var removedItem = e.OldItems?[0] as TRestrict;
                     if (removedItem == null || !removedItem.Owned)
                         break;
 
@@ -195,7 +195,7 @@ namespace Tizen.NUI.Binding
                     if (e.NewStartingIndex == -1 || e.OldStartingIndex == -1 || e.NewItems?.Count > 1)
                         goto case NotifyCollectionChangedAction.Reset;
 
-                    var newReplaceItem = e.NewItems[0] as TRestrict;
+                    var newReplaceItem = e.NewItems?[0] as TRestrict;
                     var oldReplaceItem = e.OldItems?[0] as TRestrict;
 
                     if ((newReplaceItem == null || !newReplaceItem.Owned) && (oldReplaceItem == null || !oldReplaceItem.Owned))
index 8586d24..2902186 100755 (executable)
@@ -32,7 +32,7 @@ namespace Tizen.NUI.Binding
                 () =>
                 (MemberInfo)Property.DeclaringType.GetRuntimeProperty(Property.PropertyName) ?? (MemberInfo)Property.DeclaringType.GetRuntimeMethod("Get" + Property.PropertyName, new[] { typeof(BindableObject) });
 
-            object value = valueconverter.Convert(Value, Property.ReturnType, minforetriever, serviceProvider);
+            object value = valueconverter?.Convert(Value, Property.ReturnType, minforetriever, serviceProvider);
             Value = value;
             return this;
         }
index 508de0a..ac69c4e 100755 (executable)
@@ -7,9 +7,11 @@ namespace Tizen.NUI.StyleSheets
     {
         public static IEnumerable<StyleSheet> GetStyleSheets(this IResourcesProvider resourcesProvider)
         {
+            if (resourcesProvider == null)
+                yield break;
             if (!resourcesProvider.IsResourcesCreated)
                 yield break;
-            if (resourcesProvider.XamlResources.StyleSheets == null)
+            if (resourcesProvider.XamlResources == null || resourcesProvider.XamlResources.StyleSheets == null)
                 yield break;
             foreach (var styleSheet in resourcesProvider.XamlResources.StyleSheets)
                 yield return styleSheet;
index 5b7355e..ab806ac 100755 (executable)
@@ -288,11 +288,11 @@ namespace Tizen.NUI
         {
             if (!BaseHandle.ReferenceEquals(x, null) || !BaseHandle.ReferenceEquals(y, null))
             {
-                if (x.HasBody())
+                if (x != null && x.HasBody())
                 {
                     return x;
                 }
-                if (y.HasBody())
+                if (y != null && y.HasBody())
                 {
                     return y;
                 }