From e606d3cb5573d956aa4df58fbe39a21b8c423860 Mon Sep 17 00:00:00 2001 From: Diadlo Date: Sat, 19 Aug 2017 16:18:43 +0300 Subject: [PATCH] fix(group): Fix crash on group quit Fix 'GroupWidget' removing --- src/widget/friendlistwidget.cpp | 6 ++++++ src/widget/friendlistwidget.h | 1 + src/widget/widget.cpp | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/widget/friendlistwidget.cpp b/src/widget/friendlistwidget.cpp index 6a5a4bf7c..9abc7f3ef 100644 --- a/src/widget/friendlistwidget.cpp +++ b/src/widget/friendlistwidget.cpp @@ -296,6 +296,12 @@ void FriendListWidget::addFriendWidget(FriendWidget* w, Status s, int circleInde circleWidget->addFriendWidget(w, s); } +void FriendListWidget::removeGroupWidget(GroupWidget* w) +{ + groupLayout.removeSortedWidget(w); + w->deleteLater(); +} + void FriendListWidget::removeFriendWidget(FriendWidget* w) { const Friend* contact = w->getFriend(); diff --git a/src/widget/friendlistwidget.h b/src/widget/friendlistwidget.h index 3d7a1ac87..973f24385 100644 --- a/src/widget/friendlistwidget.h +++ b/src/widget/friendlistwidget.h @@ -51,6 +51,7 @@ public: void addGroupWidget(GroupWidget* widget); void addFriendWidget(FriendWidget* w, Status s, int circleIndex); + void removeGroupWidget(GroupWidget* w); void removeFriendWidget(FriendWidget* w); void addCircleWidget(int id); void addCircleWidget(FriendWidget* widget = nullptr); diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 36793ee03..cb4b9b5d3 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -1791,7 +1791,8 @@ void Widget::removeGroup(Group* g, bool fake) groupWidgets.remove(groupId); Nexus::getCore()->removeGroup(groupId, fake); - delete widget; + contactListWidget->removeGroupWidget(widget); + delete g; if (contentLayout && contentLayout->mainHead->layout()->isEmpty()) { onAddClicked();