Adding Ownership to SafeHandleCommandList 44/129744/2 accepted/tizen/unified/20170518.185230 submit/tizen/20170518.082049
authormanish.r <manish.r@samsung.com>
Thu, 18 May 2017 04:26:22 +0000 (09:56 +0530)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 18 May 2017 08:15:53 +0000 (17:15 +0900)
Change-Id: Iae8fa643f47d2f4e267e256bc45aca8f4022b7dd
Signed-off-by: manish.r <manish.r@samsung.com>
Tizen.Uix.VoiceControl/Interop/Interop.VoiceControlCommand.cs
Tizen.Uix.VoiceControl/Tizen.Uix.VoiceControl/RecognitionResult.cs
Tizen.Uix.VoiceControl/Tizen.Uix.VoiceControl/VoiceControlClient.cs

index b9ca66e..c29057a 100755 (executable)
@@ -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)
index 4fb5ea8..99469e9 100755 (executable)
@@ -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);
         }
index f9d689a..200f2d9 100755 (executable)
@@ -205,7 +205,6 @@ namespace Tizen.Uix.VoiceControl
         /// <param name="evt">The ResultEvent</param>
         /// <param name="cmdList">Command List</param>
         /// <param name="result">Result</param>
-        public delegate void RecognitionResultDelegate(ResultEvent evt, VoiceCommandList cmdList, string result);
 
         private static event EventHandler<RecognitionResultEventArgs> _recognitionResult;
         private static event EventHandler<StateChangedEventArgs> _stateChanged;