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

fix(friendwidget): Use queued connection to avoid removing 'this'

Fix #4966

Since 'removeAction' can remove friend (who would have thought?) it must be
connectd queued to avoid use after free.
This commit is contained in:
Diadlo 2018-02-21 20:51:01 +03:00
parent 3780acffe8
commit 9b4972e045
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727

View File

@ -195,7 +195,8 @@ void FriendWidget::onContextMenuCalled(QContextMenuEvent* event)
if (!contentDialog || !contentDialog->hasFriendWidget(friendId, this)) {
const auto removeAction = menu.addAction(
tr("Remove friend", "Menu to remove the friend from our friendlist"));
connect(removeAction, &QAction::triggered, [=]() { emit removeFriend(friendId); });
connect(removeAction, &QAction::triggered, this, [=]() { emit removeFriend(friendId); },
Qt::QueuedConnection);
}
menu.addSeparator();