From: manish.r Date: Thu, 18 May 2017 04:26:22 +0000 (+0530) Subject: Adding Ownership to SafeHandleCommandList X-Git-Tag: submit/trunk/20170823.075128~68^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d394904adf7f68518fd11462eb1e8ab3f3611450;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Adding Ownership to SafeHandleCommandList Change-Id: Iae8fa643f47d2f4e267e256bc45aca8f4022b7dd Signed-off-by: manish.r --- diff --git a/src/Tizen.Uix.VoiceControl/Interop/Interop.VoiceControlCommand.cs b/src/Tizen.Uix.VoiceControl/Interop/Interop.VoiceControlCommand.cs index b9ca66e..c29057a 100755 --- a/src/Tizen.Uix.VoiceControl/Interop/Interop.VoiceControlCommand.cs +++ b/src/Tizen.Uix.VoiceControl/Interop/Interop.VoiceControlCommand.cs @@ -95,14 +95,18 @@ internal static partial class Interop internal sealed class SafeCommandListHandle : SafeHandle { + internal bool _ownership; + public SafeCommandListHandle(IntPtr handle) : base(handle, true) { + _ownership = true; } public SafeCommandListHandle() : base(IntPtr.Zero, true) { + _ownership = true; } public override bool IsInvalid @@ -112,7 +116,7 @@ internal static partial class Interop protected override bool ReleaseHandle() { - if (!IsInvalid) + if (_ownership && !IsInvalid) { Interop.VoiceControl.ErrorCode error = VcCmdListDestroy(this.handle, false); if (error != Interop.VoiceControl.ErrorCode.None) diff --git a/src/Tizen.Uix.VoiceControl/Tizen.Uix.VoiceControl/RecognitionResult.cs b/src/Tizen.Uix.VoiceControl/Tizen.Uix.VoiceControl/RecognitionResult.cs index 4fb5ea8..99469e9 100755 --- a/src/Tizen.Uix.VoiceControl/Tizen.Uix.VoiceControl/RecognitionResult.cs +++ b/src/Tizen.Uix.VoiceControl/Tizen.Uix.VoiceControl/RecognitionResult.cs @@ -37,6 +37,7 @@ namespace Tizen.Uix.VoiceControl { _resultEvent = evt; SafeCommandListHandle handle = new SafeCommandListHandle(cmdList); + handle._ownership = false; _list = new VoiceCommandList(handle); _result = Marshal.PtrToStringAnsi(result); } diff --git a/src/Tizen.Uix.VoiceControl/Tizen.Uix.VoiceControl/VoiceControlClient.cs b/src/Tizen.Uix.VoiceControl/Tizen.Uix.VoiceControl/VoiceControlClient.cs index f9d689a..200f2d9 100755 --- a/src/Tizen.Uix.VoiceControl/Tizen.Uix.VoiceControl/VoiceControlClient.cs +++ b/src/Tizen.Uix.VoiceControl/Tizen.Uix.VoiceControl/VoiceControlClient.cs @@ -205,7 +205,6 @@ namespace Tizen.Uix.VoiceControl /// The ResultEvent /// Command List /// Result - public delegate void RecognitionResultDelegate(ResultEvent evt, VoiceCommandList cmdList, string result); private static event EventHandler _recognitionResult; private static event EventHandler _stateChanged;