Browse Source

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.
reviewable/pr4967/r2
Diadlo 8 years ago
parent
commit
9b4972e045
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
  1. 3
      src/widget/friendwidget.cpp

3
src/widget/friendwidget.cpp

@ -195,7 +195,8 @@ void FriendWidget::onContextMenuCalled(QContextMenuEvent* event) @@ -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();

Loading…
Cancel
Save