diff --git a/packaging/csapi-tizenfx.spec b/packaging/csapi-tizenfx.spec index f2e2e5f1c75..0a68736722a 100644 --- a/packaging/csapi-tizenfx.spec +++ b/packaging/csapi-tizenfx.spec @@ -1,7 +1,7 @@ # Auto-generated from csapi-tizenfx.spec.in by makespec.sh %define TIZEN_NET_API_VERSION 12 -%define TIZEN_NET_RPM_VERSION 12.0.0.999+nui22344 +%define TIZEN_NET_RPM_VERSION 12.0.0.999+nui22345 %define TIZEN_NET_NUGET_VERSION 12.0.0.99999 %define DOTNET_ASSEMBLY_PATH /usr/share/dotnet.tizen/framework diff --git a/packaging/version.txt b/packaging/version.txt index 0ae0d7ca3c8..239e8a19ed2 100755 --- a/packaging/version.txt +++ b/packaging/version.txt @@ -6,4 +6,4 @@ RPM_VERSION=12.0.0.999 NUGET_VERSION=12.0.0.99999 # RPM Version Suffix -RPM_VERSION_SUFFIX=nui22344 +RPM_VERSION_SUFFIX=nui22345 diff --git a/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/SyncAdapter.cs b/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/SyncAdapter.cs index d135f6a6932..f7c4e8087e1 100755 --- a/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/SyncAdapter.cs +++ b/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/SyncAdapter.cs @@ -42,6 +42,7 @@ public class SyncAdapter /// /// 4 /// The sync job parameters corresponding to the sync request. + [Obsolete("Deprecated since API12. Might be removed in API14")] public delegate void CancelSyncCallback(SyncJobData syncParameters); /// diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Dataset.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Dataset.cs index cfaf094c2a0..5658d4faa8e 100644 --- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Dataset.cs +++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Dataset.cs @@ -37,6 +37,9 @@ public class Dataset: IDisposable private IntPtr handle = IntPtr.Zero; private bool disposed = false; + /// if false, model will be destroy dataset handle + private bool hasOwnership = true; + /// /// Constructs the dataset. /// @@ -44,6 +47,9 @@ public class Dataset: IDisposable public Dataset() { NNTrainerError ret = Interop.Dataset.Create(out handle); + if (ret != NNTrainerError.None) { + handle = IntPtr.Zero; + } NNTrainer.CheckException(ret, "Failed to create dataset instance"); Log.Info(NNTrainer.Tag, "Create Dataset"); } @@ -82,6 +88,14 @@ protected virtual void Dispose(bool disposing) { // release managed object } + + disposed = true; + + if (!hasOwnership){ + Log.Info(NNTrainer.Tag, "Cannot destroy dataset already added in a Model. Model will destroy this dataset"); + return; + } + // release unmanaged object if (handle != IntPtr.Zero) { @@ -92,7 +106,6 @@ protected virtual void Dispose(bool disposing) handle = IntPtr.Zero; } - disposed = true; } /// @@ -124,6 +137,11 @@ internal IntPtr GetHandle() return handle; } + internal void RemoveOwnership() + { + this.hasOwnership = false; + } + /// /// Sets the neural network dataset property. /// diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs index 8f66059aa7d..db19839f520 100644 --- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs +++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs @@ -49,6 +49,9 @@ public class Layer: IDisposable public Layer(NNTrainerLayerType type) { NNTrainerError ret = Interop.Layer.Create(out handle, type); + if (ret != NNTrainerError.None) { + handle = IntPtr.Zero; + } NNTrainer.CheckException(ret, "Failed to create model instance"); Log.Info(NNTrainer.Tag, $"Create layer with type:{type}"); } @@ -98,7 +101,7 @@ protected virtual void Dispose(bool disposing) disposed = true; if (!hasOwnership){ - Log.Error(NNTrainer.Tag, "Cannot destroy layer already added in a Model. Model will destroy this layer"); + Log.Info(NNTrainer.Tag, "Cannot destroy layer already added in a Model. Model will destroy this layer"); return; } diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs index d92636e0f57..fa6a86fa44e 100644 --- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs +++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs @@ -65,6 +65,9 @@ public Model(string modelConf) NNTrainer.CheckException(NNTrainerError.InvalidParameter, "modelConf is null"); NNTrainerError ret = Interop.Model.ConstructWithConf(modelConf, out handle); + if (ret != NNTrainerError.None) { + handle = IntPtr.Zero; + } NNTrainer.CheckException(ret, "Failed to create model instance with modelConf"); Log.Info(NNTrainer.Tag, "Created Model with Conf path: "+ modelConf); } @@ -281,7 +284,7 @@ public void AddLayer(Layer layer) public Layer GetLayer(string layerName) { IntPtr layerHandle = IntPtr.Zero; - if (string.IsNullOrEmpty(layerName)) + if (string.IsNullOrEmpty(layerName)) NNTrainer.CheckException(NNTrainerError.InvalidParameter, "layerName is null"); NNTrainerError ret = Interop.Model.GetLayer(handle, layerName, out layerHandle); @@ -311,6 +314,7 @@ public void SetOptimizer(Optimizer optimizer) NNTrainerError ret = Interop.Model.SetOptimizer(handle, optimizer.GetHandle()); NNTrainer.CheckException(ret, "Failed to set optimizer"); + optimizer.RemoveOwnership(); } /// @@ -335,6 +339,7 @@ public void SetDataset(Dataset dataset) NNTrainerError ret = Interop.Model.SetDataset(handle, dataset.GetHandle()); NNTrainer.CheckException(ret, "Failed to set dataset"); + dataset.RemoveOwnership(); } internal static TensorsInfo CreateTensorsInfoFormHandle(IntPtr handle) diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Optimizer.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Optimizer.cs index de7bdf389c3..e10174e3d18 100644 --- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Optimizer.cs +++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Optimizer.cs @@ -37,6 +37,9 @@ public class Optimizer: IDisposable private IntPtr handle = IntPtr.Zero; private bool disposed = false; + /// if false, model will be destroy optimizer handle + private bool hasOwnership = true; + /// /// Creates a neural network optimizer. /// @@ -45,6 +48,9 @@ public class Optimizer: IDisposable public Optimizer(NNTrainerOptimizerType type) { NNTrainerError ret = Interop.Optimizer.Create(out handle, type); + if (ret != NNTrainerError.None) { + handle = IntPtr.Zero; + } NNTrainer.CheckException(ret, "Failed to create optimizer instance"); Log.Info(NNTrainer.Tag, $"Create optimizer with type:{type}"); } @@ -83,6 +89,14 @@ protected virtual void Dispose(bool disposing) { // release managed object } + + disposed = true; + + if (!hasOwnership){ + Log.Info(NNTrainer.Tag, "Cannot destroy optimizer already added in a Model. Model will destroy this optimizer"); + return; + } + // release unmanaged object if (handle != IntPtr.Zero) { @@ -93,7 +107,6 @@ protected virtual void Dispose(bool disposing) handle = IntPtr.Zero; } - disposed = true; } /// @@ -122,5 +135,10 @@ internal IntPtr GetHandle() { return handle; } + + internal void RemoveOwnership() + { + this.hasOwnership = false; + } } } diff --git a/src/Tizen.NUI/src/internal/Common/EnumHelper.cs b/src/Tizen.NUI/src/internal/Common/EnumHelper.cs index 7de41f9085c..44554f8b1f8 100755 --- a/src/Tizen.NUI/src/internal/Common/EnumHelper.cs +++ b/src/Tizen.NUI/src/internal/Common/EnumHelper.cs @@ -74,7 +74,7 @@ public static T GetValueByDescription(this string description) where T : stru } } - var value = type.GetFields(BindingFlags.Public | BindingFlags.Static).FirstOrDefault().GetValue(null); + var value = type.GetFields(BindingFlags.Public | BindingFlags.Static).FirstOrDefault()?.GetValue(null); return value != null ? (T)value : default(T); //throw new ArgumentException($"{description} can't be found.", "Description"); } diff --git a/src/Tizen.NUI/src/internal/Common/PropertyHelper.cs b/src/Tizen.NUI/src/internal/Common/PropertyHelper.cs index 8c5be950dad..203a2fb1f78 100755 --- a/src/Tizen.NUI/src/internal/Common/PropertyHelper.cs +++ b/src/Tizen.NUI/src/internal/Common/PropertyHelper.cs @@ -30,12 +30,10 @@ internal static class PropertyHelper { private static readonly Dictionary visualPropertyTable = new Dictionary() { - { "backgroundColor", new VisualPropertyData(View.Property.BACKGROUND, ColorVisualProperty.MixColor, ObjectColorToVector3, PropertyValueColorToVector3, - new VisualPropertyData(View.Property.BACKGROUND, Visual.Property.Opacity, ObjectColorToAlpha, PropertyValueColorToAlpha)) }, + { "backgroundColor", new VisualPropertyData(View.Property.BACKGROUND, ColorVisualProperty.MixColor, ObjectColorToVector4, PropertyValueColorToVector4) }, { "backgroundOpacity", new VisualPropertyData(View.Property.BACKGROUND, Visual.Property.Opacity, ObjectIntToFloat) }, { "boxShadow.BlurRadius", new VisualPropertyData(View.Property.SHADOW, ColorVisualProperty.BlurRadius) }, - { "boxShadow.Color", new VisualPropertyData(View.Property.SHADOW, ColorVisualProperty.MixColor, ObjectColorToVector3, PropertyValueColorToVector3, - new VisualPropertyData(View.Property.SHADOW, Visual.Property.Opacity, ObjectColorToAlpha, PropertyValueColorToAlpha)) }, + { "boxShadow.Color", new VisualPropertyData(View.Property.SHADOW, ColorVisualProperty.MixColor, ObjectColorToVector4, PropertyValueColorToVector4) }, { "boxShadow.CornerRadius", new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerRadius, ObjectIntToFloat) }, { "boxShadow.Offset", new VisualPropertyData(View.Property.SHADOW, (int)VisualTransformPropertyType.Offset) }, { "boxShadow.Opacity", new VisualPropertyData(View.Property.SHADOW, Visual.Property.Opacity, ObjectIntToFloat) }, @@ -141,24 +139,24 @@ private static string LowerFirstLetter(string original) return sb.ToString(); } - private static object ObjectColorToVector3(object value) + private static object ObjectColorToVector4(object value) { if (value is Vector4) { var colorValue = value as Vector4; - return new Vector3(colorValue.R, colorValue.G, colorValue.B); + return new Vector4(colorValue.R, colorValue.G, colorValue.B, colorValue.A); } if (value is Color) { var colorValue = value as Color; - return new Vector3(colorValue.R, colorValue.G, colorValue.B); + return new Vector4(colorValue.R, colorValue.G, colorValue.B, colorValue.A); } return null; } - private static PropertyValue PropertyValueColorToVector3(PropertyValue value) + private static PropertyValue PropertyValueColorToVector4(PropertyValue value) { var valueType = value.GetType(); @@ -169,43 +167,10 @@ private static PropertyValue PropertyValueColorToVector3(PropertyValue value) var colorValue = new Vector4(); value.Get(colorValue); - using (var v3 = new Vector3(colorValue.R, colorValue.G, colorValue.B)) + using (var v4 = new Vector4(colorValue.R, colorValue.G, colorValue.B, colorValue.A)) { colorValue.Dispose(); - return new PropertyValue(v3); - } - } - - private static object ObjectColorToAlpha(object value) - { - if (value is Vector4) - { - var colorValue = value as Vector4; - return colorValue.A; - } - - if (value is Color) - { - var colorValue = value as Color; - return colorValue.A; - } - - return null; - } - - private static PropertyValue PropertyValueColorToAlpha(PropertyValue value) - { - var valueType = value.GetType(); - - if (valueType != PropertyType.Vector4) - { - return null; - } - - using (var colorValue = new Vector4()) - { - value.Get(colorValue); - return new PropertyValue(colorValue.A); + return new PropertyValue(v4); } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/AddToDictionary.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/AddToDictionary.cs index ddd7eee7852..e5f50532089 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/AddToDictionary.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/AddToDictionary.cs @@ -44,7 +44,7 @@ public void Do() var type = dict.GetType(); var method = type.GetMethods().FirstOrDefault(m => m.Name == "Add"); - method.Invoke(dict, new object[] { key, value }); + method?.Invoke(dict, new object[] { key, value }); } private int parentIndex; diff --git a/src/Tizen.NUI/src/internal/WebView/WebContext.cs b/src/Tizen.NUI/src/internal/WebView/WebContext.cs index c8bad400905..9a4469c7122 100755 --- a/src/Tizen.NUI/src/internal/WebView/WebContext.cs +++ b/src/Tizen.NUI/src/internal/WebView/WebContext.cs @@ -40,6 +40,8 @@ public class WebContext : Disposable private readonly WebContextPasswordDataListAcquiredProxyCallback passwordDataListAcquiredProxyCallback; private HttpRequestInterceptedCallback httpRequestInterceptedCallback; private readonly WebContextHttpRequestInterceptedProxyCallback httpRequestInterceptedProxyCallback; + private DownloadStartedCallback downloadStartedCallback; + private MimeOverriddenCallback mimeOverriddenCallback; internal WebContext(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) { @@ -518,10 +520,11 @@ public void GetFormPasswordList(PasswordDataListAcquiredCallback callback) [EditorBrowsable(EditorBrowsableState.Never)] public void RegisterDownloadStartedCallback(DownloadStartedCallback callback) { + downloadStartedCallback = callback; IntPtr ip = IntPtr.Zero; - if (callback != null) + if (downloadStartedCallback != null) { - ip = Marshal.GetFunctionPointerForDelegate(callback); + ip = Marshal.GetFunctionPointerForDelegate(downloadStartedCallback); } Interop.WebContext.RegisterDownloadStartedCallback(SwigCPtr, new HandleRef(this, ip)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -534,10 +537,11 @@ public void RegisterDownloadStartedCallback(DownloadStartedCallback callback) [EditorBrowsable(EditorBrowsableState.Never)] public void RegisterMimeOverriddenCallback(MimeOverriddenCallback callback) { + mimeOverriddenCallback = callback; IntPtr ip = IntPtr.Zero; - if (callback != null) + if (mimeOverriddenCallback != null) { - ip = Marshal.GetFunctionPointerForDelegate(callback); + ip = Marshal.GetFunctionPointerForDelegate(mimeOverriddenCallback); } Interop.WebContext.RegisterMimeOverriddenCallback(SwigCPtr, new HandleRef(this, ip)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs index cf134a84b2b..0c6e68b51da 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs @@ -496,7 +496,7 @@ internal void SetParentOrigin(Position origin) internal Position GetCurrentParentOrigin() { - if(internalCurrentParentOrigin == null) + if (internalCurrentParentOrigin == null) { internalCurrentParentOrigin = new Position(0, 0, 0); } @@ -520,7 +520,7 @@ internal void SetAnchorPoint(Position anchorPoint) internal Position GetCurrentAnchorPoint() { - if(internalCurrentAnchorPoint == null) + if (internalCurrentAnchorPoint == null) { internalCurrentAnchorPoint = new Position(0, 0, 0); } @@ -565,7 +565,7 @@ internal void SetSize(Vector3 size) internal Vector3 GetTargetSize() { - if(internalTargetSize == null) + if (internalTargetSize == null) { internalTargetSize = new Vector3(0, 0, 0); } @@ -582,7 +582,7 @@ internal Vector3 GetTargetSize() internal Size2D GetCurrentSize() { - if(internalCurrentSize == null) + if (internalCurrentSize == null) { internalCurrentSize = new Size2D(0, 0); } @@ -647,7 +647,7 @@ internal void TranslateBy(Vector3 distance) internal Position GetCurrentPosition() { - if(internalCurrentPosition == null) + if (internalCurrentPosition == null) { internalCurrentPosition = new Position(0, 0, 0); } @@ -663,7 +663,7 @@ internal Position GetCurrentPosition() internal Vector3 GetCurrentWorldPosition() { - if(internalCurrentWorldPosition == null) + if (internalCurrentWorldPosition == null) { internalCurrentWorldPosition = new Vector3(0, 0, 0); } @@ -680,7 +680,7 @@ internal Vector3 GetCurrentWorldPosition() internal Vector2 GetCurrentScreenPosition() { - if(internalCurrentScreenPosition == null) + if (internalCurrentScreenPosition == null) { internalCurrentScreenPosition = new Vector2(0, 0); } @@ -792,7 +792,7 @@ internal void SetScale(Vector3 scale) internal Vector3 GetCurrentScale() { - if(internalCurrentScale == null) + if (internalCurrentScale == null) { internalCurrentScale = new Vector3(0, 0, 0); } @@ -809,7 +809,7 @@ internal Vector3 GetCurrentScale() internal Vector3 GetCurrentWorldScale() { - if(internalCurrentWorldScale == null) + if (internalCurrentWorldScale == null) { internalCurrentWorldScale = new Vector3(0, 0, 0); } @@ -886,7 +886,7 @@ internal float GetCurrentOpacity() internal Vector4 GetCurrentColor() { - if(internalCurrentColor == null) + if (internalCurrentColor == null) { internalCurrentColor = new Vector4(0, 0, 0, 0); } @@ -910,7 +910,7 @@ internal ColorMode GetColorMode() internal Vector4 GetCurrentWorldColor() { - if(internalCurrentWorldColor == null) + if (internalCurrentWorldColor == null) { internalCurrentWorldColor = new Vector4(0, 0, 0, 0); } @@ -1002,12 +1002,12 @@ internal ResizePolicyType GetResizePolicy(DimensionType dimension) internal Vector3 GetSizeModeFactor() { - if (internalSizeModeFactor == null) - { - internalSizeModeFactor = new Vector3(OnSizeModeFactorChanged, 0, 0, 0); - } - Object.InternalRetrievingPropertyVector3(SwigCPtr, View.Property.SizeModeFactor, internalSizeModeFactor.SwigCPtr); - return internalSizeModeFactor; + if (internalSizeModeFactor == null) + { + internalSizeModeFactor = new Vector3(OnSizeModeFactorChanged, 0, 0, 0); + } + Object.InternalRetrievingPropertyVector3(SwigCPtr, View.Property.SizeModeFactor, internalSizeModeFactor.SwigCPtr); + return internalSizeModeFactor; } internal void SetMinimumSize(Vector2 size) @@ -1437,7 +1437,10 @@ protected override void Dispose(DisposeTypes type) foreach (View view in Children) { - view.InternalParent = null; + if (view != null) + { + view.InternalParent = null; + } } if (themeData != null) @@ -1746,7 +1749,7 @@ private void DisConnectFromSignals() if (readingSkippedCallback != null) { NUILog.Debug($"[Dispose] readingSkippedCallback"); - + ReadingSkippedSignal?.Disconnect(readingSkippedCallback); ReadingSkippedSignal?.Dispose(); ReadingSkippedSignal = null; diff --git a/src/Tizen.NUI/src/public/CustomView/CustomViewRegistry.cs b/src/Tizen.NUI/src/public/CustomView/CustomViewRegistry.cs index 1a40e45cf51..02f51201c85 100755 --- a/src/Tizen.NUI/src/public/CustomView/CustomViewRegistry.cs +++ b/src/Tizen.NUI/src/public/CustomView/CustomViewRegistry.cs @@ -406,7 +406,7 @@ private void SetPropertyValue(IntPtr refObjectPtr, string propertyName, IntPtr p View view = Registry.GetManagedBaseHandleFromRefObject(refObjectPtr) as View; if (view != null) { - System.Reflection.PropertyInfo propertyInfo = view.GetType().GetProperty(propertyName); + System.Reflection.PropertyInfo propertyInfo = view.GetType().GetProperty(propertyName) ?? throw new global::System.InvalidOperationException("propertyInfo is null! can not set any value!"); // We know the property name, we know it's type, we just need to convert from a DALi property value to native C# type System.Type type = propertyInfo?.PropertyType; bool ok = false; diff --git a/src/Tizen.NUI/src/public/WebView/WebView.cs b/src/Tizen.NUI/src/public/WebView/WebView.cs index 94e127f2cb1..2a3fbe4d233 100755 --- a/src/Tizen.NUI/src/public/WebView/WebView.cs +++ b/src/Tizen.NUI/src/public/WebView/WebView.cs @@ -244,6 +244,10 @@ protected override void Dispose(DisposeTypes type) return; } + Context.RegisterDownloadStartedCallback(null); + Context.RegisterMimeOverriddenCallback(null); + Context.RegisterHttpRequestInterceptedCallback(null); + if (type == DisposeTypes.Explicit) { //Called by User