[AccountManager] Improving resource handling - Issues 67,68 & 69 (#611)
authorabhishekvijay <40332812+abhishekvijay@users.noreply.github.com>
Wed, 26 Dec 2018 00:59:21 +0000 (06:29 +0530)
committerSeungkeun Lee <sngn.lee@samsung.com>
Wed, 26 Dec 2018 00:59:21 +0000 (09:59 +0900)
* Improving resource handling - Issues 67,68 & 69

Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
* Incorporating review comments

Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
* Removed 'tabs' and used spaces for correcting indent

Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/SafeAccountHandle.cs

index 04af81c..0498fb5 100644 (file)
@@ -623,7 +623,7 @@ namespace Tizen.Account.AccountManager
         /// <param name="disposing">The boolean value for destoying account handle.</param>
         protected virtual void Dispose(bool disposing)
         {
-            if (!disposing)
+            if (disposing)
             {
                 _handle.Dispose();
             }
index 88b0428..374adcc 100644 (file)
@@ -106,7 +106,7 @@ namespace Tizen.Account.AccountManager
             List<int> values = new List<int>();
             Interop.Account.AccountCallback accountCallback = (IntPtr data, IntPtr userdata) =>
             {
-                Account account = new Account(new SafeAccountHandle(data, true));
+                Account account = new Account(new SafeAccountHandle(data, false));
                 values.Add(account.AccountId);
                 account.Dispose();
                 return true;
@@ -150,7 +150,7 @@ namespace Tizen.Account.AccountManager
                 throw AccountErrorFactory.CreateException(res, "Failed to get accounts from the database for account id: " + accountId);
             }
             Account ref_account = new Account(handle);
-                       
+
             return ref_account;
         }
 
@@ -403,7 +403,7 @@ namespace Tizen.Account.AccountManager
             List<int> values = new List<int>();
             Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
             {
-                Account account = new Account(new SafeAccountHandle(handle, true));
+                Account account = new Account(new SafeAccountHandle(handle, false));
                 values.Add(account.AccountId);
                 account.Dispose();
                 return true;
@@ -442,7 +442,7 @@ namespace Tizen.Account.AccountManager
             List<int> values = new List<int>();
             Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
             {
-                Account account = new Account(new SafeAccountHandle(handle, true));
+                Account account = new Account(new SafeAccountHandle(handle, false));
                 values.Add(account.AccountId);
                 account.Dispose();
                 return true;
@@ -481,7 +481,7 @@ namespace Tizen.Account.AccountManager
             List<int> values = new List<int>();
             Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
             {
-                Account account = new Account(new SafeAccountHandle(handle, true));
+                Account account = new Account(new SafeAccountHandle(handle, false));
                 values.Add(account.AccountId);
                 account.Dispose();
                 return true;
index abdf95e..159d04f 100644 (file)
@@ -60,6 +60,7 @@ namespace Tizen.Account.AccountManager
         /// <returns>true if the handle is released successfully</returns>
         protected override bool ReleaseHandle()
         {
+            Interop.Account.Destroy(this.handle);
             this.SetHandle(IntPtr.Zero);
             return true;
         }