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:
parent
993f6fa5c0
commit
bef9d4b773
|
@ -270,7 +270,7 @@ void Nexus::setProfile(Profile* profile)
|
||||||
{
|
{
|
||||||
getInstance().profile = profile;
|
getInstance().profile = profile;
|
||||||
if (profile)
|
if (profile)
|
||||||
Settings::getInstance().loadPersonal(profile);
|
Settings::getInstance().loadPersonal(profile->getName(), profile->getPasskey());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -96,14 +96,16 @@ void Profile::initCore(const QByteArray& toxsave, ICoreSettings& s, bool isNewPr
|
||||||
Qt::ConnectionType::QueuedConnection);
|
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}
|
: name{name}
|
||||||
|
, passkey{std::move(passkey)}
|
||||||
, isRemoved{false}
|
, isRemoved{false}
|
||||||
|
, encrypted{this->passkey != nullptr}
|
||||||
{
|
{
|
||||||
Settings& s = Settings::getInstance();
|
Settings& s = Settings::getInstance();
|
||||||
s.setCurrentProfile(name);
|
s.setCurrentProfile(name);
|
||||||
s.saveGlobal();
|
s.saveGlobal();
|
||||||
|
s.loadPersonal(name, passkey.get());
|
||||||
initCore(toxsave, s, isNewProfile);
|
initCore(toxsave, s, isNewProfile);
|
||||||
|
|
||||||
const ToxId& selfId = core->getSelfId();
|
const ToxId& selfId = core->getSelfId();
|
||||||
|
@ -180,12 +182,7 @@ Profile* Profile::loadProfile(QString name, const QString& password)
|
||||||
}
|
}
|
||||||
|
|
||||||
saveFile.close();
|
saveFile.close();
|
||||||
p = new Profile(name, password, false, data);
|
p = new Profile(name, password, false, data, std::move(tmpKey));
|
||||||
p->passkey = std::move(tmpKey);
|
|
||||||
if (p->passkey) {
|
|
||||||
p->encrypted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
// cleanup in case of error
|
// cleanup in case of error
|
||||||
|
@ -230,12 +227,7 @@ Profile* Profile::createProfile(QString name, QString password)
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::getInstance().createPersonal(name);
|
Settings::getInstance().createPersonal(name);
|
||||||
Profile* p = new Profile(name, password, true, QByteArray());
|
Profile* p = new Profile(name, password, true, QByteArray(), std::move(tmpKey));
|
||||||
p->passkey = std::move(tmpKey);
|
|
||||||
if (p->passkey) {
|
|
||||||
p->encrypted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ private slots:
|
||||||
void onAvatarOfferReceived(uint32_t friendId, uint32_t fileId, const QByteArray& avatarHash);
|
void onAvatarOfferReceived(uint32_t friendId, uint32_t fileId, const QByteArray& avatarHash);
|
||||||
|
|
||||||
private:
|
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);
|
static QStringList getFilesByExt(QString extension);
|
||||||
QString avatarPath(const ToxPk& owner, bool forceUnencrypted = false);
|
QString avatarPath(const ToxPk& owner, bool forceUnencrypted = false);
|
||||||
bool saveToxSave(QByteArray data);
|
bool saveToxSave(QByteArray data);
|
||||||
|
|
|
@ -273,17 +273,7 @@ void Settings::loadGlobal()
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::loadPersonal()
|
void Settings::loadPersonal(QString profileName, const ToxEncrypt* passKey)
|
||||||
{
|
|
||||||
Profile* profile = Nexus::getProfile();
|
|
||||||
if (!profile) {
|
|
||||||
qCritical() << "No active profile, couldn't load personal settings";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
loadPersonal(profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Settings::loadPersonal(Profile* profile)
|
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&bigLock};
|
QMutexLocker locker{&bigLock};
|
||||||
|
|
||||||
|
@ -291,13 +281,13 @@ void Settings::loadPersonal(Profile* profile)
|
||||||
QString filePath = dir.filePath(globalSettingsFile);
|
QString filePath = dir.filePath(globalSettingsFile);
|
||||||
|
|
||||||
// load from a profile specific friend data list if possible
|
// 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
|
if (QFile(tmp).exists()) // otherwise, filePath remains the global file
|
||||||
filePath = tmp;
|
filePath = tmp;
|
||||||
|
|
||||||
qDebug() << "Loading personal settings from" << filePath;
|
qDebug() << "Loading personal settings from" << filePath;
|
||||||
|
|
||||||
SettingsSerializer ps(filePath, profile->getPasskey());
|
SettingsSerializer ps(filePath, passKey);
|
||||||
ps.load();
|
ps.load();
|
||||||
friendLst.clear();
|
friendLst.clear();
|
||||||
|
|
||||||
|
|
|
@ -146,8 +146,7 @@ public:
|
||||||
void savePersonal();
|
void savePersonal();
|
||||||
|
|
||||||
void loadGlobal();
|
void loadGlobal();
|
||||||
void loadPersonal();
|
void loadPersonal(QString profileName, const ToxEncrypt* passKey);
|
||||||
void loadPersonal(Profile* profile);
|
|
||||||
|
|
||||||
void resetToDefault();
|
void resetToDefault();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user