From 22667e429970aa339dbb3976b64748a22d5a0455 Mon Sep 17 00:00:00 2001 From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> Date: Fri, 21 Apr 2017 15:47:47 -0400 Subject: [PATCH] pendingcontact: fix nullptr access fixing non-checked defered pointer, that can be null. Change-Id: I37b0226731852f052a0f5bffaff8a9d05a3cf7c1 --- src/pendingcontactrequests.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/pendingcontactrequests.cpp b/src/pendingcontactrequests.cpp index 6e0e12ec..7343da28 100644 --- a/src/pendingcontactrequests.cpp +++ b/src/pendingcontactrequests.cpp @@ -76,16 +76,17 @@ pending_contact_requests_view_init(PendingContactRequestsView *self) // the next signal is used to set the model in function of the selection of the account QObject::connect(AvailableAccountModel::instance().selectionModel(), &QItemSelectionModel::currentChanged, [self](const QModelIndex& idx){ - auto account = idx.data(static_cast<int>(Account::Role::Object)).value<Account*>(); - GtkQTreeModel *pending_contact_requests_model; - pending_contact_requests_model = gtk_q_tree_model_new( - account->pendingContactRequestModel(), - 1/*nmbr. of cols.*/, - 0, - Qt::DisplayRole, - G_TYPE_STRING); - - gtk_tree_view_set_model(GTK_TREE_VIEW(self), GTK_TREE_MODEL(pending_contact_requests_model)); + if (auto account = idx.data(static_cast<int>(Account::Role::Object)).value<Account*>()) { + GtkQTreeModel *pending_contact_requests_model; + pending_contact_requests_model = gtk_q_tree_model_new( + account->pendingContactRequestModel(), + 1/*nmbr. of cols.*/, + 0, + Qt::DisplayRole, + G_TYPE_STRING); + + gtk_tree_view_set_model(GTK_TREE_VIEW(self), GTK_TREE_MODEL(pending_contact_requests_model)); + } }); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); -- GitLab