[ComponentBased][TCSACR-282] Add Release method to IWindowInfo interface (#1040)
authorHyunho Kang <hhstark.kang@samsung.com>
Tue, 1 Oct 2019 02:07:30 +0000 (11:07 +0900)
committerGitHub <noreply@github.com>
Tue, 1 Oct 2019 02:07:30 +0000 (11:07 +0900)
* Modify native api name

Signed-off-by: hyunho <hhstark.kang@samsung.com>
* Add argument check logic

SendLaunchRequestAsync control parameter should not be null

Signed-off-by: hyunho <hhstark.kang@samsung.com>
* Add argument check logic

SendLaunchRequestAsync control parameter should not be null

Signed-off-by: hyunho <hhstark.kang@samsung.com>
* Add Release method to IWindowInfo interface

Signed-off-by: hyunho <hhstark.kang@samsung.com>
* Use IDisposable to release window resource

Signed-off-by: hyunho <hhstark.kang@samsung.com>
* Fix indention

Signed-off-by: hyunho <hhstark.kang@samsung.com>
* Fix dispose method

Signed-off-by: hyunho <hhstark.kang@samsung.com>
src/Tizen.Applications.ComponentBased.Default/Tizen.Applications.ComponentBased.Default/EFLWindowInfo.cs [changed mode: 0755->0644]
src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/FrameComponentStateManager.cs [changed mode: 0755->0644]
src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/IWindowInfo.cs

old mode 100755 (executable)
new mode 100644 (file)
index d2ba807..e899a0c
@@ -13,6 +13,7 @@ namespace Tizen.Applications.ComponentBased.Default
         private const string LogTag = "Tizen.Applications";
         private Window _win;
         private int _resId;
+        private bool _disposed = false;
 
         /// <summary>
         /// Initializes the EFLWindow class.
@@ -44,6 +45,34 @@ namespace Tizen.Applications.ComponentBased.Default
             }
         }
 
+        /// <summary>
+        /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            if (disposing)
+            {
+                _win.Unrealize();
+                _win = null;
+            }
+            _disposed = true;
+        }
+
+        /// <summary>
+        /// Dispose the window resources
+        /// </summary>
+        /// <returns></returns>
+        /// <since_tizen> 6 </since_tizen>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
     }
 
 }
old mode 100755 (executable)
new mode 100644 (file)
index f850e8d..702ce48
@@ -8,6 +8,7 @@ namespace Tizen.Applications.ComponentBased.Common
     {
         private Interop.CBApplication.FrameLifecycleCallbacks _callbacks;
         private const string LogTag = "Tizen.Applications";
+        private IDictionary<string, IWindowInfo> _winDic = new Dictionary<string, IWindowInfo>();
 
         internal FrameComponentStateManager(Type ctype, string id, ComponentBasedApplication parent) : base(ctype, id, parent)
         {
@@ -47,6 +48,7 @@ namespace Tizen.Applications.ComponentBased.Common
             if (win == null)
                 return IntPtr.Zero;
 
+            _winDic.Add(id, win);
             if (!fc.OnCreate())
             {
                 Log.Error(LogTag, "OnCreate fail");
@@ -115,6 +117,7 @@ namespace Tizen.Applications.ComponentBased.Common
                 if (fc.Handle == context)
                 {
                     fc.OnDestroy();
+                    _winDic[fc.Id].Dispose();
                     RemoveComponent(fc);
                     break;
                 }
index 16df436..61bfb7c 100644 (file)
@@ -6,7 +6,7 @@ namespace Tizen.Applications.ComponentBased.Common
     /// Interface for window information
     /// </summary>
     /// <since_tizen> 6 </since_tizen>
-    public interface IWindowInfo
+    public interface IWindowInfo : IDisposable
     {
         /// <summary>
         /// Gets window resource ID