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

fix(profile): load settings before starting Core

This is a quick fix to load settings before Core is started. Ideally
this would not need to be inside the Profile, but at the moment the
decryption key is not available before starting Core.
This commit is contained in:
sudden6 2019-08-25 14:44:33 +02:00
parent 4d84db1a4e
commit bb26d4a086
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
2 changed files with 5 additions and 3 deletions

View File

@ -291,7 +291,7 @@ Profile::Profile(const QString& name, const QString& password, std::unique_ptr<T
*
* @note If the profile is already in use return nullptr.
*/
Profile* Profile::loadProfile(const QString& name, const QString& password, const Settings& settings)
Profile* Profile::loadProfile(const QString& name, const QString& password, Settings& settings)
{
if (ProfileLocker::hasLock()) {
qCritical() << "Tried to load profile " << name << ", but another profile is already locked!";
@ -307,7 +307,6 @@ Profile* Profile::loadProfile(const QString& name, const QString& password, cons
QByteArray toxsave = QByteArray();
QString path = settings.getSettingsDirPath() + name + ".tox";
std::unique_ptr<ToxEncrypt> tmpKey = loadToxData(password, path, toxsave, error);
if (logLoadToxDataError(error, path)) {
ProfileLocker::unlock();
return nullptr;
@ -315,6 +314,9 @@ Profile* Profile::loadProfile(const QString& name, const QString& password, cons
Profile* p = new Profile(name, password, std::move(tmpKey));
// Core settings are saved per profile, need to load them before starting Core
settings.loadPersonal(name, tmpKey.get());
p->initCore(toxsave, settings, /*isNewProfile*/ false);
p->loadDatabase(password);

View File

@ -41,7 +41,7 @@ class Profile : public QObject
Q_OBJECT
public:
static Profile* loadProfile(const QString& name, const QString& password, const Settings& settings);
static Profile* loadProfile(const QString& name, const QString& password, Settings& settings);
static Profile* createProfile(const QString& name, const QString& password,
const Settings& settings);
~Profile();