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

fix(profileform): Fixed very quick relogin segfault

This commit is contained in:
Diadlo 2016-04-12 01:59:03 +03:00 committed by Polshakov Dmitry
parent 2e9295f420
commit 88de3a0a7a

View File

@ -480,25 +480,28 @@ void ProfileForm::onRegisterButtonClicked()
if (name.isEmpty()) if (name.isEmpty())
return; return;
Core* oldCore = Core::getInstance();
Toxme::ExecCode code = Toxme::ExecCode::Ok; Toxme::ExecCode code = Toxme::ExecCode::Ok;
QString response = Toxme::createAddress(code, server, id, name, privacy, bio); QString response = Toxme::createAddress(code, server, id, name, privacy, bio);
if (Core::getInstance()) Core* newCore = Core::getInstance();
if (oldCore == newCore)
{ {
switch (code) { switch (code) {
case Toxme::Updated: case Toxme::Updated:
QMessageBox::information(this, tr("Done!"), tr("Account %1@%2 updated successfully").arg(name, server), "Ok"); GUI::showInfo(tr("Done!"), tr("Account %1@%2 updated successfully").arg(name, server));
Settings::getInstance().setToxme(name, server, bio, privacy); Settings::getInstance().setToxme(name, server, bio, privacy);
showExistenToxme(); showExistenToxme();
break; break;
case Toxme::Ok: case Toxme::Ok:
QMessageBox::information(this, tr("Done!"), tr("Successfully added %1@%2 to the database. Save your password").arg(name, server), "Ok"); GUI::showInfo(tr("Done!"), tr("Successfully added %1@%2 to the database. Save your password").arg(name, server));
Settings::getInstance().setToxme(name, server, bio, privacy, response); Settings::getInstance().setToxme(name, server, bio, privacy, response);
showExistenToxme(); showExistenToxme();
break; break;
default: default:
QString errorMessage = Toxme::getErrorMessage(code); QString errorMessage = Toxme::getErrorMessage(code);
QMessageBox::warning(this, tr("Toxme error"), errorMessage, "Ok"); GUI::showWarning(tr("Toxme error"), errorMessage);
} }
bodyUI->toxmeRegisterButton->setEnabled(true); bodyUI->toxmeRegisterButton->setEnabled(true);