From 88de3a0a7a09b89b0a621452e53b4d6d4ec3bfe8 Mon Sep 17 00:00:00 2001 From: Diadlo Date: Tue, 12 Apr 2016 01:59:03 +0300 Subject: [PATCH] fix(profileform): Fixed very quick relogin segfault --- src/widget/form/profileform.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/widget/form/profileform.cpp b/src/widget/form/profileform.cpp index d50541239..e99ae9629 100644 --- a/src/widget/form/profileform.cpp +++ b/src/widget/form/profileform.cpp @@ -480,25 +480,28 @@ void ProfileForm::onRegisterButtonClicked() if (name.isEmpty()) return; + Core* oldCore = Core::getInstance(); + Toxme::ExecCode code = Toxme::ExecCode::Ok; QString response = Toxme::createAddress(code, server, id, name, privacy, bio); - if (Core::getInstance()) + Core* newCore = Core::getInstance(); + if (oldCore == newCore) { switch (code) { 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); showExistenToxme(); break; 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); showExistenToxme(); break; default: QString errorMessage = Toxme::getErrorMessage(code); - QMessageBox::warning(this, tr("Toxme error"), errorMessage, "Ok"); + GUI::showWarning(tr("Toxme error"), errorMessage); } bodyUI->toxmeRegisterButton->setEnabled(true);