1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Fix crash if call failed to start

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-10-25 11:29:25 +02:00
parent 38da22dded
commit 7b70fd0008
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
5 changed files with 36 additions and 4 deletions

View File

@ -185,6 +185,7 @@ signals:
void avRequestTimeout(int friendId, int callIndex);
void avPeerTimeout(int friendId, int callIndex);
void avMediaChange(int friendId, int callIndex, bool videoEnabled);
void avCallFailed(int friendId);
void videoFrameReceived(vpx_image* frame);

View File

@ -142,15 +142,32 @@ void Core::startCall(int friendId, bool video)
{
qDebug() << QString("Core: Starting new call with %1 with video").arg(friendId);
cSettings.call_type = TypeVideo;
toxav_call(toxav, &callId, friendId, &cSettings, TOXAV_RINGING_TIME);
calls[callId].videoEnabled=true;
if (toxav_call(toxav, &callId, friendId, &cSettings, TOXAV_RINGING_TIME) == 0)
{
calls[callId].videoEnabled=true;
}
else
{
qWarning() << QString("Core: Failed to start new video call with %1").arg(friendId);
emit avCallFailed(friendId);
return;
}
}
else
{
qDebug() << QString("Core: Starting new call with %1 without video").arg(friendId);
cSettings.call_type = TypeAudio;
toxav_call(toxav, &callId, friendId, &cSettings, TOXAV_RINGING_TIME);
calls[callId].videoEnabled=false;
if (toxav_call(toxav, &callId, friendId, &cSettings, TOXAV_RINGING_TIME) == 0)
{
calls[callId].videoEnabled=false;
}
else
{
qWarning() << QString("Core: Failed to start new audio call with %1").arg(friendId);
emit avCallFailed(friendId);
return;
}
}
}

View File

@ -459,6 +459,18 @@ void ChatForm::onVideoCallTriggered()
emit startVideoCall(f->friendId, true);
}
void ChatForm::onAvCallFailed(int FriendId)
{
if (FriendId != f->friendId)
return;
audioInputFlag = false;
callButton->disconnect();
videoButton->disconnect();
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
}
void ChatForm::onCancelCallTriggered()
{
audioInputFlag = false;

View File

@ -55,6 +55,7 @@ public slots:
void onAvRequestTimeout(int FriendId, int CallId);
void onAvPeerTimeout(int FriendId, int CallId);
void onAvMediaChange(int FriendId, int CallId, bool video);
void onAvCallFailed(int FriendId);
void onMicMuteToggle();
void onAvatarChange(int FriendId, const QPixmap& pic);
void onAvatarRemoved(int FriendId);

View File

@ -620,6 +620,7 @@ void Widget::addFriend(int friendId, const QString &userId)
connect(core, &Core::avRequestTimeout, newfriend->chatForm, &ChatForm::onAvRequestTimeout);
connect(core, &Core::avPeerTimeout, newfriend->chatForm, &ChatForm::onAvPeerTimeout);
connect(core, &Core::avMediaChange, newfriend->chatForm, &ChatForm::onAvMediaChange);
connect(core, &Core::avCallFailed, newfriend->chatForm, &ChatForm::onAvCallFailed);
connect(core, &Core::friendAvatarChanged, newfriend->chatForm, &ChatForm::onAvatarChange);
connect(core, &Core::friendAvatarChanged, newfriend->widget, &FriendWidget::onAvatarChange);
connect(core, &Core::friendAvatarRemoved, newfriend->chatForm, &ChatForm::onAvatarRemoved);