gui: do not attempt to create context menu if idlist is empty

...and other side effects
This commit is contained in:
chelovechishko 2018-07-02 17:41:26 +09:00
parent 57cff61873
commit 4eb060e154

View file

@ -246,8 +246,8 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
void ChatLobbyDialog::textBrowserAskContextMenu(QMenu* contextMnu, QString anchorForPosition, const QPoint /*point*/) void ChatLobbyDialog::textBrowserAskContextMenu(QMenu* contextMnu, QString anchorForPosition, const QPoint /*point*/)
{ {
if (anchorForPosition.startsWith(PERSONID)){ if (anchorForPosition.startsWith(PERSONID)) {
QString strId = anchorForPosition.replace(PERSONID,""); QString strId = anchorForPosition.replace(PERSONID, "");
if (strId.contains(" ")) if (strId.contains(" "))
strId.truncate(strId.indexOf(" ")); strId.truncate(strId.indexOf(" "));
@ -263,6 +263,8 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
{ {
if (!contextMnu) if (!contextMnu)
return; return;
if (idList.isEmpty())
return;
contextMnu->addAction(distantChatAct); contextMnu->addAction(distantChatAct);
contextMnu->addAction(sendMessageAct); contextMnu->addAction(sendMessageAct);
@ -281,7 +283,7 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
votePositiveAct->setEnabled(false); votePositiveAct->setEnabled(false);
voteNeutralAct->setEnabled(false); voteNeutralAct->setEnabled(false);
voteNegativeAct->setEnabled(false); voteNegativeAct->setEnabled(false);
showInPeopleAct->setEnabled(idList.count()==1); showInPeopleAct->setEnabled(idList.count() == 1);
distantChatAct->setData(QVariant::fromValue(idList)); distantChatAct->setData(QVariant::fromValue(idList));
sendMessageAct->setData(QVariant::fromValue(idList)); sendMessageAct->setData(QVariant::fromValue(idList));
@ -291,8 +293,6 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
voteNegativeAct->setData(QVariant::fromValue(idList)); voteNegativeAct->setData(QVariant::fromValue(idList));
showInPeopleAct->setData(QVariant::fromValue(idList)); showInPeopleAct->setData(QVariant::fromValue(idList));
if(idList.count()==1)
{
RsGxsId gxsid = idList.at(0); RsGxsId gxsid = idList.at(0);
if(!gxsid.isNull() && !rsIdentity->isOwnId(gxsid)) if(!gxsid.isNull() && !rsIdentity->isOwnId(gxsid))
@ -304,7 +304,6 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
muteAct->setEnabled(true); muteAct->setEnabled(true);
muteAct->setChecked(isParticipantMuted(gxsid)); muteAct->setChecked(isParticipantMuted(gxsid));
} }
}
} }
void ChatLobbyDialog::voteParticipant() void ChatLobbyDialog::voteParticipant()