Browse Source

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.
reviewable/pr6181/r3
Anthony Bilinski 5 years ago
parent
commit
5dcea74db5
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 9
      src/persistence/profile.cpp
  2. 3
      src/persistence/profile.h

9
src/persistence/profile.cpp

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

3
src/persistence/profile.h

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

Loading…
Cancel
Save