1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix: Fix crash on accept or reject friend request

Fix #4603
This commit is contained in:
Diadlo 2017-08-28 23:17:59 +03:00
parent 22732b6f79
commit 359a42f78e
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727

View File

@ -314,8 +314,8 @@ void AddFriendForm::onFriendRequestAccepted()
QPushButton* acceptButton = static_cast<QPushButton*>(sender());
QWidget* friendWidget = acceptButton->parentWidget();
const int index = requestsLayout->indexOf(friendWidget);
const int indexFromEnd = requestsLayout->count() - index - 1;
removeFriendRequestWidget(friendWidget);
const int indexFromEnd = requestsLayout->count() - index - 1;
const Settings::Request request = Settings::getInstance().getFriendRequest(indexFromEnd);
emit friendRequestAccepted(ToxId(request.address).getPublicKey());
Settings::getInstance().removeFriendRequest(indexFromEnd);
@ -327,8 +327,8 @@ void AddFriendForm::onFriendRequestRejected()
QPushButton* rejectButton = static_cast<QPushButton*>(sender());
QWidget* friendWidget = rejectButton->parentWidget();
const int index = requestsLayout->indexOf(friendWidget);
const int indexFromEnd = requestsLayout->count() - index - 1;
removeFriendRequestWidget(friendWidget);
const int indexFromEnd = requestsLayout->count() - index - 1;
Settings::getInstance().removeFriendRequest(indexFromEnd);
Settings::getInstance().savePersonal();
}