diff --git a/src/core.cpp b/src/core.cpp index 8791d428e..fa25ca7fd 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -238,15 +238,17 @@ void Core::start() QByteArray savedata = loadToxSave(loadPath); + make_tox(savedata); + // Do we need to create a new save & profile? if (savedata.isNull()) { qDebug() << "Save file not found, creating a new profile"; Settings::getInstance().load(); + setStatusMessage(tr("Toxing on qTox")); + setUsername(tr("qTox User")); } - make_tox(savedata); - qsrand(time(nullptr)); /** TODO: Review this mess. Actually rewrite it all @@ -278,14 +280,6 @@ void Core::start() // loadPath is meaningless after this loadPath = ""; } - else // new ID - { - QString id = getSelfId().toString(); - if (!id.isEmpty()) - emit idSet(id); - setStatusMessage(tr("Toxing on qTox")); // this also solves the not updating issue - setUsername(tr("qTox User")); - } */ // set GUI with user and statusmsg @@ -357,6 +351,15 @@ void Core::start() ready = true; + // If we created a new profile earlier, + // now that we're ready save it and ONLY THEN broadcast the new ID. + // This is useful for e.g. the profileForm that searches for saves. + if (savedata.isNull()) + { + saveConfiguration(); + emit idSet(getSelfId().toString()); + } + process(); // starts its own timer } diff --git a/src/widget/form/profileform.cpp b/src/widget/form/profileform.cpp index 68c5bc06a..0e05d4d11 100644 --- a/src/widget/form/profileform.cpp +++ b/src/widget/form/profileform.cpp @@ -183,6 +183,7 @@ void ProfileForm::setToxId(const QString& id) qr = new QRWidget(); qr->setQRData("tox:"+id); bodyUI->qrCode->setPixmap(QPixmap::fromImage(qr->getImage()->scaledToWidth(150))); + refreshProfiles(); } void ProfileForm::onAvatarClicked()