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

fix(settings): load personal settings before constructing core

Fix proxy settings not being passed to toxcore, bug present since
8574162949. Not present in any releases.
This commit is contained in:
Anthony Bilinski 2019-03-28 20:34:01 -07:00
parent 993f6fa5c0
commit bef9d4b773
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
5 changed files with 13 additions and 32 deletions

View File

@ -270,7 +270,7 @@ void Nexus::setProfile(Profile* profile)
{
getInstance().profile = profile;
if (profile)
Settings::getInstance().loadPersonal(profile);
Settings::getInstance().loadPersonal(profile->getName(), profile->getPasskey());
}
/**

View File

@ -96,14 +96,16 @@ void Profile::initCore(const QByteArray& toxsave, ICoreSettings& s, bool isNewPr
Qt::ConnectionType::QueuedConnection);
}
Profile::Profile(QString name, const QString& password, bool isNewProfile, const QByteArray& toxsave)
Profile::Profile(QString name, const QString& password, bool isNewProfile, const QByteArray& toxsave, std::unique_ptr<ToxEncrypt> passkey)
: name{name}
, passkey{std::move(passkey)}
, isRemoved{false}
, encrypted{this->passkey != nullptr}
{
Settings& s = Settings::getInstance();
s.setCurrentProfile(name);
s.saveGlobal();
s.loadPersonal(name, passkey.get());
initCore(toxsave, s, isNewProfile);
const ToxId& selfId = core->getSelfId();
@ -180,12 +182,7 @@ Profile* Profile::loadProfile(QString name, const QString& password)
}
saveFile.close();
p = new Profile(name, password, false, data);
p->passkey = std::move(tmpKey);
if (p->passkey) {
p->encrypted = true;
}
p = new Profile(name, password, false, data, std::move(tmpKey));
return p;
// cleanup in case of error
@ -230,12 +227,7 @@ Profile* Profile::createProfile(QString name, QString password)
}
Settings::getInstance().createPersonal(name);
Profile* p = new Profile(name, password, true, QByteArray());
p->passkey = std::move(tmpKey);
if (p->passkey) {
p->encrypted = true;
}
Profile* p = new Profile(name, password, true, QByteArray(), std::move(tmpKey));
return p;
}

View File

@ -98,7 +98,7 @@ private slots:
void onAvatarOfferReceived(uint32_t friendId, uint32_t fileId, const QByteArray& avatarHash);
private:
Profile(QString name, const QString& password, bool newProfile, const QByteArray& toxsave);
Profile(QString name, const QString& password, bool newProfile, const QByteArray& toxsave, std::unique_ptr<ToxEncrypt> passKey);
static QStringList getFilesByExt(QString extension);
QString avatarPath(const ToxPk& owner, bool forceUnencrypted = false);
bool saveToxSave(QByteArray data);

View File

@ -273,17 +273,7 @@ void Settings::loadGlobal()
loaded = true;
}
void Settings::loadPersonal()
{
Profile* profile = Nexus::getProfile();
if (!profile) {
qCritical() << "No active profile, couldn't load personal settings";
return;
}
loadPersonal(profile);
}
void Settings::loadPersonal(Profile* profile)
void Settings::loadPersonal(QString profileName, const ToxEncrypt* passKey)
{
QMutexLocker locker{&bigLock};
@ -291,13 +281,13 @@ void Settings::loadPersonal(Profile* profile)
QString filePath = dir.filePath(globalSettingsFile);
// load from a profile specific friend data list if possible
QString tmp = dir.filePath(profile->getName() + ".ini");
QString tmp = dir.filePath(profileName + ".ini");
if (QFile(tmp).exists()) // otherwise, filePath remains the global file
filePath = tmp;
qDebug() << "Loading personal settings from" << filePath;
SettingsSerializer ps(filePath, profile->getPasskey());
SettingsSerializer ps(filePath, passKey);
ps.load();
friendLst.clear();

View File

@ -146,8 +146,7 @@ public:
void savePersonal();
void loadGlobal();
void loadPersonal();
void loadPersonal(Profile* profile);
void loadPersonal(QString profileName, const ToxEncrypt* passKey);
void resetToDefault();