diff --git a/src/widget/form/groupchatform.cpp b/src/widget/form/groupchatform.cpp index 76e0f05d6..f5aff8c85 100644 --- a/src/widget/form/groupchatform.cpp +++ b/src/widget/form/groupchatform.cpp @@ -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 nickLabelList(peersCount); @@ -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(netcam)->addPeer(peerNumber, fullName); } peerLabels.append(label); @@ -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(); diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index cb40ba27d..134902921 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -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();