Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix: two crashes, uncovered by the persistent groupchat patch
Browse files Browse the repository at this point in the history
  • Loading branch information
sudden6 committed May 2, 2018
1 parent 498c04b commit 48179b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/widget/form/groupchatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -245,9 +250,9 @@ void GroupChatForm::updateUserNames()

if (group->isSelfPeerNumber(peerNumber)) {
label->setStyleSheet(QStringLiteral("QLabel {color : green;}"));
} else if (s.getBlackList().contains(peerPk.toString())) {
} else if (s.getBlackList().contains(peerPk.toString())) {
label->setStyleSheet(QStringLiteral("QLabel {color : darkRed;}"));
} else if (netcam != nullptr) {
} else if (netcam != nullptr) {
static_cast<GroupNetCamView*>(netcam)->addPeer(peerNumber, fullName);
}
peerLabels.append(label);
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/widget/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 48179b6

Please sign in to comment.