Browse Source

fix(settings): repair saved invalid proxy type due to #5311

reviewable/pr5455/r3
Anthony Bilinski 7 years ago
parent
commit
c8ffa1f921
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 1
      src/core/icoresettings.h
  2. 15
      src/persistence/settings.cpp
  3. 1
      src/persistence/settings.h

1
src/core/icoresettings.h

@ -12,6 +12,7 @@ class ICoreSettings { @@ -12,6 +12,7 @@ class ICoreSettings {
public:
enum class ProxyType
{
// If changed, don't forget to update Settings::fixInvalidProxyType
ptNone = 0,
ptSOCKS5 = 1,
ptHTTP = 2

15
src/persistence/settings.cpp

@ -402,6 +402,7 @@ void Settings::loadPersonal(Profile* profile) @@ -402,6 +402,7 @@ void Settings::loadPersonal(Profile* profile)
ps.beginGroup("Proxy");
{
proxyType = static_cast<ProxyType>(ps.value("proxyType", 0 /* ProxyType::None */).toInt());
proxyType = fixInvalidProxyType(proxyType);
proxyAddr = ps.value("proxyAddr", proxyAddr).toString();
proxyPort = static_cast<quint16>(ps.value("proxyPort", proxyPort).toUInt());
}
@ -2444,3 +2445,17 @@ Settings::friendProp& Settings::getOrInsertFriendPropRef(const ToxPk& id) @@ -2444,3 +2445,17 @@ Settings::friendProp& Settings::getOrInsertFriendPropRef(const ToxPk& id)
return *it;
}
ICoreSettings::ProxyType Settings::fixInvalidProxyType(ICoreSettings::ProxyType proxyType)
{
// Repair uninitialized enum that was saved to settings due to bug (https://github.com/qTox/qTox/issues/5311)
switch (proxyType) {
case ICoreSettings::ProxyType::ptNone:
case ICoreSettings::ProxyType::ptSOCKS5:
case ICoreSettings::ProxyType::ptHTTP:
return proxyType;
default:
qWarning() << "Repairing invalid ProxyType, UDP will be enabled";
return ICoreSettings::ProxyType::ptNone;
}
}

1
src/persistence/settings.h

@ -578,6 +578,7 @@ private: @@ -578,6 +578,7 @@ private:
Settings& operator=(const Settings&) = delete;
void savePersonal(QString profileName, const ToxEncrypt* passkey);
friendProp& getOrInsertFriendPropRef(const ToxPk& id);
ICoreSettings::ProxyType fixInvalidProxyType(ICoreSettings::ProxyType proxyType);
public slots:
void savePersonal(Profile* profile);

Loading…
Cancel
Save