Browse Source

fix: two crashes, uncovered by the persistent groupchat patch

reviewable/pr5113/r3
sudden6 7 years ago
parent
commit
48179b6a19
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
  1. 6
      src/widget/form/groupchatform.cpp
  2. 2
      src/widget/widget.cpp

6
src/widget/form/groupchatform.cpp

@ -224,6 +224,11 @@ void GroupChatForm::updateUserNames() @@ -224,6 +224,11 @@ void GroupChatForm::updateUserNames()
peerLabels.clear();
const int peersCount = group->getPeersCount();
// no need to do anything without a peer
if (peersCount == 0) {
return;
}
peerLabels.reserve(peersCount);
QVector<QLabel*> nickLabelList(peersCount);
@ -262,6 +267,7 @@ void GroupChatForm::updateUserNames() @@ -262,6 +267,7 @@ void GroupChatForm::updateUserNames()
{
return a->text().toLower() < b->text().toLower();
});
// remove comma from last sorted label
QLabel* const lastLabel = nickLabelList.last();
QString labelText = lastLabel->text();

2
src/widget/widget.cpp

@ -1869,8 +1869,8 @@ void Widget::removeGroup(Group* g, bool fake) @@ -1869,8 +1869,8 @@ void Widget::removeGroup(Group* g, bool fake)
qWarning() << "Tried to remove group" << groupId << "but GroupChatForm doesn't exist";
return;
}
groupChatForms.erase(groupChatFormIt);
delete groupChatFormIt.value();
groupChatForms.erase(groupChatFormIt);
delete g;
if (contentLayout && contentLayout->mainHead->layout()->isEmpty()) {
onAddClicked();

Loading…
Cancel
Save