TizenRefApp-6953 Crash when initiating outgoing call 77/84377/2
authorSergei Kobec <s.kobec@samsung.com>
Thu, 18 Aug 2016 08:44:03 +0000 (11:44 +0300)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 18 Aug 2016 14:34:24 +0000 (07:34 -0700)
TizenRefApp-6955 Crash when adding some MFC to favourites

Change-Id: I36b573ca208fd33cef7a2e9b295c742137b64974
Signed-off-by: Sergei Kobec <s.kobec@samsung.com>
lib-contacts/src/Contacts/List/Model/MfcProvider.cpp
lib-contacts/src/Contacts/List/Model/PersonProvider.cpp

index 2b2e4c5..5e95351 100644 (file)
@@ -64,15 +64,17 @@ contacts_record_h MfcProvider::getPersonRecord(int id, PersonProvider::IdType id
                return nullptr;
        }
 
-       for (auto &&usageRecord : makeRange(getPersonUsageList())) {
+       contacts_record_h record = nullptr;
+       contacts_list_h list = getPersonUsageList();
+       for (auto &&usageRecord : makeRange(list)) {
                if (getRecordInt(usageRecord, _contacts_person_usage.person_id) == id) {
-                       contacts_record_h record = nullptr;
                        contacts_db_get_record(_contacts_person._uri, id, &record);
-                       return record;
+                       break;
                }
        }
 
-       return nullptr;
+       contacts_list_destroy(list, true);
+       return record;
 }
 
 void MfcProvider::insertPerson(contacts_record_h personRecord)
index ef85258..322fa57 100644 (file)
@@ -78,7 +78,7 @@ void PersonProvider::reload()
                PersonProvider::insertPerson(record);
        }
 
-       contacts_list_destroy(list, true);
+       contacts_list_destroy(list, false);
 }
 
 void PersonProvider::setUpdateMode(bool isEnabled)
@@ -287,7 +287,7 @@ void PersonProvider::updatePersonList()
                        case CONTACTS_CHANGE_UPDATED:
                        {
                                int personId = getPersonId(contactId);
-                               contacts_record_h personRecord = getPersonRecord(contactId, ContactId);
+                               contacts_record_h personRecord = getPersonRecord(personId, PersonId);
                                auto personIt = findPerson(personId, PersonId);
 
                                if (personIt != m_PersonList.end()) {