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

fix: Fix crash on manipulation with friend

Fix #4991
This commit is contained in:
Diadlo 2018-03-11 22:50:22 +03:00
parent e3726eade6
commit 2a0c71d0d4
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727

View File

@ -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)
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)
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();