[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 04af81c912ee021a7d7c5aca6d308a4a40332a3a..0498fb5f8d1ecb94cdccaeb4f1378c20866eb335 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 88b0428436025992fa6a50e72018ab5e32431678..374adcc3ee66a0810c25274975197c18ce236359 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 abdf95e6b7efa909bb16c57aacb9be0d0f15b867..159d04fc8c7e5f2621dce359b6d8bd3bf8d9b58e 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;
         }