Browse Source

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.
reviewable/pr5797/r2
sudden6 6 years ago
parent
commit
bb26d4a086
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
  1. 6
      src/persistence/profile.cpp
  2. 2
      src/persistence/profile.h

6
src/persistence/profile.cpp

@ -291,7 +291,7 @@ Profile::Profile(const QString& name, const QString& password, std::unique_ptr<T @@ -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 @@ -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 @@ -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);

2
src/persistence/profile.h

@ -41,7 +41,7 @@ class Profile : public QObject @@ -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();

Loading…
Cancel
Save