Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(settings): repair saved invalid proxy type due to #5311
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonybilinski committed Dec 9, 2018
1 parent e80dbe2 commit c8ffa1f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/icoresettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions src/persistence/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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 change: 1 addition & 0 deletions src/persistence/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ public slots:
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);
Expand Down

0 comments on commit c8ffa1f

Please sign in to comment.