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

fix(core): read proxy type after personal settings are loaded

Profile is required to load personal settings, and Profile was creating the
bootstraplist using personal settings. Instead create the bootstraplist in
initCore, after personal settings have been loaded. This avoids using an
uninitialized proxy type on every profile load.
This commit is contained in:
Anthony Bilinski 2020-07-01 11:54:30 -07:00
parent 8dfd108cb8
commit 5dcea74db5
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
2 changed files with 8 additions and 4 deletions

View File

@ -244,8 +244,11 @@ void Profile::initCore(const QByteArray& toxsave, const ICoreSettings& s, bool i
emit failedToStart(); emit failedToStart();
} }
bootstrapNodes = std::unique_ptr<BootstrapNodeUpdater>(
new BootstrapNodeUpdater(Settings::getInstance().getProxy(), paths));
Core::ToxCoreErrors err; Core::ToxCoreErrors err;
core = Core::makeToxCore(toxsave, &s, bootstrapNodes, &err); core = Core::makeToxCore(toxsave, &s, *bootstrapNodes, &err);
if (!core) { if (!core) {
switch (err) { switch (err) {
case Core::ToxCoreErrors::BAD_PROXY: case Core::ToxCoreErrors::BAD_PROXY:
@ -279,12 +282,12 @@ void Profile::initCore(const QByteArray& toxsave, const ICoreSettings& s, bool i
avatarBroadcaster = std::unique_ptr<AvatarBroadcaster>(new AvatarBroadcaster(*core)); avatarBroadcaster = std::unique_ptr<AvatarBroadcaster>(new AvatarBroadcaster(*core));
} }
Profile::Profile(const QString& name, const QString& password, std::unique_ptr<ToxEncrypt> passkey, Paths& paths) Profile::Profile(const QString& name, const QString& password, std::unique_ptr<ToxEncrypt> passkey, Paths& paths_)
: name{name} : name{name}
, passkey{std::move(passkey)} , passkey{std::move(passkey)}
, isRemoved{false} , isRemoved{false}
, encrypted{this->passkey != nullptr} , encrypted{this->passkey != nullptr}
, bootstrapNodes(Settings::getInstance().getProxy(), paths) , paths{paths_}
{} {}
/** /**

View File

@ -120,5 +120,6 @@ private:
bool isRemoved; bool isRemoved;
bool encrypted = false; bool encrypted = false;
static QStringList profiles; static QStringList profiles;
BootstrapNodeUpdater bootstrapNodes; std::unique_ptr<BootstrapNodeUpdater> bootstrapNodes;
Paths& paths;
}; };