From d394904adf7f68518fd11462eb1e8ab3f3611450 Mon Sep 17 00:00:00 2001 From: "manish.r" Date: Thu, 18 May 2017 09:56:22 +0530 Subject: [PATCH] Adding Ownership to SafeHandleCommandList Change-Id: Iae8fa643f47d2f4e267e256bc45aca8f4022b7dd Signed-off-by: manish.r --- src/Tizen.Uix.VoiceControl/Interop/Interop.VoiceControlCommand.cs | 6 +++++- .../Tizen.Uix.VoiceControl/RecognitionResult.cs | 1 + .../Tizen.Uix.VoiceControl/VoiceControlClient.cs | 1 - 3 files changed, 6 insertions(+), 2 deletions(-) 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; -- 2.7.4