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

Commit

Permalink
fix(chatform): Subscribe on accept and reject buttons once
Browse files Browse the repository at this point in the history
Fix #4799

For every call was created new connection. First call was success. The second
call leaded to double answer: after the second core removes 'friendNum' from
'calls' list and cancels call. The third call leaded to triple answer, where the
first two same as before and the last one - tried to answer on call with removed
'friendNum' => assert failed.
  • Loading branch information
Diadlo committed Nov 20, 2017
1 parent f4a3bb2 commit d77fbb4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/widget/form/chatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ ChatForm::ChatForm(Friend* chatFriend)
: f(chatFriend)
, callDuration(new QLabel(this))
, isTyping(false)
, lastCallIsVideo{false}
{
setName(f->getDisplayedName());

Expand Down Expand Up @@ -190,6 +191,10 @@ ChatForm::ChatForm(Friend* chatFriend)
connect(headWidget, &ChatFormHeader::nameChanged, this, [=](const QString& newName) {
f->setAlias(newName);
});
connect(headWidget, &ChatFormHeader::callAccepted, this, [this] {
onAnswerCallTriggered(lastCallIsVideo);
});
connect(headWidget, &ChatFormHeader::callRejected, this, &ChatForm::onRejectCallTriggered);

updateCallButtons();
setAcceptDrops(true);
Expand Down Expand Up @@ -345,10 +350,7 @@ void ChatForm::onAvInvite(uint32_t friendId, bool video)
onAvStart(friendId, video);
} else {
headWidget->showCallConfirm(video);
connect(headWidget, &ChatFormHeader::callAccepted, this, [this, video] {
onAnswerCallTriggered(video);
});
connect(headWidget, &ChatFormHeader::callRejected, this, &ChatForm::onRejectCallTriggered);
lastCallIsVideo = video;
auto msg = ChatMessage::createChatInfoMessage(tr("%1 calling").arg(displayedName),
ChatMessage::INFO, QDateTime::currentDateTime());
insertChatMessage(msg);
Expand Down
1 change: 1 addition & 0 deletions src/widget/form/chatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ private slots:

QHash<uint, FileTransferInstance*> ftransWidgets;
bool isTyping;
bool lastCallIsVideo;
};

#endif // CHATFORM_H

0 comments on commit d77fbb4

Please sign in to comment.