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

fix(addfriend): create ToxId from QString before emitting the signal

fix #4086
This commit is contained in:
sudden6 2017-01-20 20:53:10 +01:00
parent 1df9f5726d
commit a5d2c573dd
No known key found for this signature in database
GPG Key ID: 279509B499E032B9

View File

@ -162,13 +162,13 @@ void AddFriendForm::onUsernameSet(const QString& username)
void AddFriendForm::onSendTriggered() void AddFriendForm::onSendTriggered()
{ {
QString id = toxId.text().trimmed(); QString idText = toxId.text().trimmed();
ToxId toxId; ToxId friendId(idText);
if (!ToxId::isValidToxId(id)) if (!friendId.isValid())
{ {
toxId = Toxme::lookup(id); // Try Toxme friendId = Toxme::lookup(idText); // Try Toxme
if (!toxId.isValid()) if (!friendId.isValid())
{ {
GUI::showWarning(tr("Couldn't add friend"), GUI::showWarning(tr("Couldn't add friend"),
tr("This Tox ID is invalid or does not exist", "Toxme error")); tr("This Tox ID is invalid or does not exist", "Toxme error"));
@ -176,13 +176,13 @@ void AddFriendForm::onSendTriggered()
} }
} }
deleteFriendRequest(toxId); deleteFriendRequest(friendId);
if (toxId == Core::getInstance()->getSelfId()) if (friendId == Core::getInstance()->getSelfId())
GUI::showWarning(tr("Couldn't add friend"), GUI::showWarning(tr("Couldn't add friend"),
tr("You can't add yourself as a friend!", tr("You can't add yourself as a friend!",
"When trying to add your own Tox ID as friend")); "When trying to add your own Tox ID as friend"));
else else
emit friendRequested(toxId, getMessage()); emit friendRequested(friendId, getMessage());
this->toxId.clear(); this->toxId.clear();
this->message.clear(); this->message.clear();