From: urmain Date: Mon, 29 Apr 2019 08:22:42 +0000 (+0900) Subject: [STT/TTS] Fix desctructor to call dispose (#596) (#800) X-Git-Tag: submit/tizen/20190430.005205~1^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69fdd8c824e1cd58afe72131a2dc5c6fccbf47b0;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [STT/TTS] Fix desctructor to call dispose (#596) (#800) Signed-off-by: sooyeon.kim --- diff --git a/src/Tizen.Uix.Stt/Tizen.Uix.Stt/SttClient.cs b/src/Tizen.Uix.Stt/Tizen.Uix.Stt/SttClient.cs old mode 100755 new mode 100644 index c057a86ce..76f70ca7a --- a/src/Tizen.Uix.Stt/Tizen.Uix.Stt/SttClient.cs +++ b/src/Tizen.Uix.Stt/Tizen.Uix.Stt/SttClient.cs @@ -363,6 +363,14 @@ namespace Tizen.Uix.Stt _handle = handle; } + /// + /// Destructor to destroy a STT instance. + /// + ~SttClient() + { + Dispose(false); + } + /// /// Event to be invoked when the recognition is done. /// @@ -1494,6 +1502,7 @@ namespace Tizen.Uix.Stt public void Dispose() { Dispose(true); + GC.SuppressFinalize(this); } /// @@ -1507,19 +1516,20 @@ namespace Tizen.Uix.Stt { if (!disposedValue) { - if (disposing) - { - lock (thisLock) - { - SttError error = SttDestroy(_handle); - if (error != SttError.None) - { - Log.Error(LogTag, "Destroy Failed with error " + error); - } - } - } - - disposedValue = true; + lock (thisLock) + { + if (_handle != IntPtr.Zero) + { + SttError error = SttDestroy(_handle); + if (error != SttError.None) + { + Log.Error(LogTag, "Destroy Failed with error " + error); + } + _handle = IntPtr.Zero; + } + } + + disposedValue = true; } } } diff --git a/src/Tizen.Uix.Tts/Tizen.Uix.Tts/TtsClient.cs b/src/Tizen.Uix.Tts/Tizen.Uix.Tts/TtsClient.cs old mode 100755 new mode 100644 index 7dab0ae76..6a53f5cee --- a/src/Tizen.Uix.Tts/Tizen.Uix.Tts/TtsClient.cs +++ b/src/Tizen.Uix.Tts/Tizen.Uix.Tts/TtsClient.cs @@ -239,6 +239,14 @@ namespace Tizen.Uix.Tts _handle = handle; } + /// + /// Destructor to destroy TtsClient handle. + /// + ~TtsClient() + { + Dispose(false); + } + /// /// Event to be invoked when TTS state changes. /// @@ -1041,6 +1049,7 @@ namespace Tizen.Uix.Tts public void Dispose() { Dispose(true); + GC.SuppressFinalize(this); } /// @@ -1053,20 +1062,21 @@ namespace Tizen.Uix.Tts protected virtual void Dispose(bool disposing) { if (!disposedValue) - { - if (disposing) - { - lock (thisLock) - { - TtsError error = TtsDestroy(_handle); - if (error != TtsError.None) - { - Log.Error(LogTag, "Destroy Failed with error " + error); - } - } - } - - disposedValue = true; + { + lock (thisLock) + { + if (_handle != IntPtr.Zero) + { + TtsError error = TtsDestroy(_handle); + if (error != TtsError.None) + { + Log.Error(LogTag, "Destroy Failed with error " + error); + } + _handle = IntPtr.Zero; + } + } + + disposedValue = true; } } }