diff --git a/src/persistence/profile.cpp b/src/persistence/profile.cpp index d75821373..2bb208769 100644 --- a/src/persistence/profile.cpp +++ b/src/persistence/profile.cpp @@ -105,10 +105,11 @@ Profile::Profile(QString name, const QString& password, bool isNewProfile, , encrypted{this->passkey != nullptr} { Settings& s = Settings::getInstance(); + // TODO(kriby): Move/refactor core initialization to remove settings dependency + // note to self: use slots/signals for this? initCore(toxsave, s, isNewProfile); - const ToxId& selfId = core->getSelfId(); - loadDatabase(selfId, password); + loadDatabase(password); } /** @@ -470,14 +471,16 @@ QByteArray Profile::loadAvatarData(const ToxPk& owner) return pic; } -void Profile::loadDatabase(const ToxId& id, QString password) +void Profile::loadDatabase(QString password) { + assert(core); + if (isRemoved) { qDebug() << "Can't load database of removed profile"; return; } - QByteArray salt = id.getPublicKey().getByteArray(); + QByteArray salt = core->getSelfId().getPublicKey().getByteArray(); if (salt.size() != TOX_PASS_SALT_LENGTH) { qWarning() << "Couldn't compute salt from public key" << name; GUI::showError(QObject::tr("Error"), diff --git a/src/persistence/profile.h b/src/persistence/profile.h index b464b6e55..6aa718525 100644 --- a/src/persistence/profile.h +++ b/src/persistence/profile.h @@ -90,7 +90,7 @@ public slots: void onRequestSent(const ToxPk& friendPk, const QString& message); private slots: - void loadDatabase(const ToxId& id, QString password); + void loadDatabase(QString password); void saveAvatar(const ToxPk& owner, const QByteArray& avatar); void removeAvatar(const ToxPk& owner); void onSaveToxSave();