From 67624a8df9b9cf6b636bfe0b199f849e2ee1ecf5 Mon Sep 17 00:00:00 2001
From: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
Date: Fri, 8 Jul 2016 16:46:07 -0400
Subject: [PATCH] recentmodel: fix Person selection

This patch fixes two bugs:
- the selectNode() function was giving the wrong pointer during idx
  creation, which caused potential segfaults
- the setCurrentIndex() function should be used instead of the select()
  function to properly select the index... this fixes the issue of
  when an incoming call is not automatically selected if a new contact
  is created for its CM (eg: during new profile transfer)

Change-Id: Ie297a570ce184559eb01fe20ae2890a6573b1bf3
Tuleap: #835
---
 src/recentmodel.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/recentmodel.cpp b/src/recentmodel.cpp
index ff3d0ea9..e3645bf1 100644
--- a/src/recentmodel.cpp
+++ b/src/recentmodel.cpp
@@ -196,7 +196,7 @@ RecentModel::getParticipantNumber(Call *call) const
 
 void RecentModelPrivate::selectNode(RecentViewNode* node) const
 {
-   const auto idx = q_ptr->createIndex(node->m_Index, 0, node->m_pParent);
+   const auto idx = q_ptr->createIndex(node->m_Index, 0, node);
 
    q_ptr->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
 }
@@ -748,7 +748,7 @@ void RecentModelPrivate::slotContactChanged(ContactMethod* cm, Person* np, Perso
         removeNode(n);
 
         if (newParentNode && newParentNode->m_lChildren.size()) {
-            q_ptr->selectionModel()->select(q_ptr->getIndex(const_cast<Person*>(newParentNode->m_uContent.m_pPerson)), QItemSelectionModel::ClearAndSelect);
+            selectNode(newParentNode);
         }
     }
 }
-- 
GitLab