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:
parent
4d84db1a4e
commit
bb26d4a086
|
@ -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);
|
||||
|
||||
|
|
|
@ -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…
Reference in New Issue
Block a user