Browse Source

fix: Fix crash on manipulation with friend

Fix #4991
pull/4997/head
Diadlo 7 years ago
parent
commit
2a0c71d0d4
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
  1. 20
      src/widget/widget.cpp

20
src/widget/widget.cpp

@ -1489,7 +1489,7 @@ void Widget::removeFriend(Friend* f, bool fake) @@ -1489,7 +1489,7 @@ void Widget::removeFriend(Friend* f, bool fake)
}
const uint32_t friendId = f->getId();
FriendWidget* widget = friendWidgets[friendId];
auto widget = friendWidgets[friendId];
widget->setAsInactiveChatroom();
if (widget == activeChatroomWidget) {
activeChatroomWidget = nullptr;
@ -1509,6 +1509,11 @@ void Widget::removeFriend(Friend* f, bool fake) @@ -1509,6 +1509,11 @@ void Widget::removeFriend(Friend* f, bool fake)
friendWidgets.remove(friendId);
delete widget;
auto chatForm = chatForms[friendId];
chatForms.remove(friendId);
delete chatForm;
delete f;
if (contentLayout && contentLayout->mainHead->layout()->isEmpty()) {
onAddClicked();
@ -1834,25 +1839,30 @@ void Widget::onGroupPeerAudioPlaying(int groupnumber, int peernumber) @@ -1834,25 +1839,30 @@ void Widget::onGroupPeerAudioPlaying(int groupnumber, int peernumber)
void Widget::removeGroup(Group* g, bool fake)
{
GroupWidget* widget = groupWidgets[g->getId()];
auto groupId = g->getId();
auto widget = groupWidgets[groupId];
widget->setAsInactiveChatroom();
if (static_cast<GenericChatroomWidget*>(widget) == activeChatroomWidget) {
activeChatroomWidget = nullptr;
onAddClicked();
}
int groupId = g->getId();
GroupList::removeGroup(groupId, fake);
ContentDialog* contentDialog = ContentDialog::getGroupDialog(groupId);
if (contentDialog != nullptr) {
contentDialog->removeGroup(groupId);
}
groupWidgets.remove(groupId);
Nexus::getCore()->removeGroup(groupId, fake);
contactListWidget->removeGroupWidget(widget);
groupWidgets.remove(groupId);
delete widget;
auto chatForm = groupChatForms[groupId];
groupChatForms.remove(groupId);
delete chatForm;
delete g;
if (contentLayout && contentLayout->mainHead->layout()->isEmpty()) {
onAddClicked();

Loading…
Cancel
Save