From d77fbb4b1999da2e20d5ed0071b254eea99dce4b Mon Sep 17 00:00:00 2001 From: Diadlo Date: Sat, 18 Nov 2017 02:06:46 +0300 Subject: [PATCH] fix(chatform): Subscribe on accept and reject buttons once 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. --- src/widget/form/chatform.cpp | 10 ++++++---- src/widget/form/chatform.h | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 64cc89434..54dd9462f 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -113,6 +113,7 @@ ChatForm::ChatForm(Friend* chatFriend) : f(chatFriend) , callDuration(new QLabel(this)) , isTyping(false) + , lastCallIsVideo{false} { setName(f->getDisplayedName()); @@ -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); @@ -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); diff --git a/src/widget/form/chatform.h b/src/widget/form/chatform.h index c9420c23b..078134efb 100644 --- a/src/widget/form/chatform.h +++ b/src/widget/form/chatform.h @@ -134,6 +134,7 @@ private: QHash ftransWidgets; bool isTyping; + bool lastCallIsVideo; }; #endif // CHATFORM_H