mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(settings): repair saved invalid proxy type due to #5311
This commit is contained in:
parent
e80dbe2d83
commit
c8ffa1f921
@ -12,6 +12,7 @@ class ICoreSettings {
|
|||||||
public:
|
public:
|
||||||
enum class ProxyType
|
enum class ProxyType
|
||||||
{
|
{
|
||||||
|
// If changed, don't forget to update Settings::fixInvalidProxyType
|
||||||
ptNone = 0,
|
ptNone = 0,
|
||||||
ptSOCKS5 = 1,
|
ptSOCKS5 = 1,
|
||||||
ptHTTP = 2
|
ptHTTP = 2
|
||||||
|
@ -402,6 +402,7 @@ void Settings::loadPersonal(Profile* profile)
|
|||||||
ps.beginGroup("Proxy");
|
ps.beginGroup("Proxy");
|
||||||
{
|
{
|
||||||
proxyType = static_cast<ProxyType>(ps.value("proxyType", 0 /* ProxyType::None */).toInt());
|
proxyType = static_cast<ProxyType>(ps.value("proxyType", 0 /* ProxyType::None */).toInt());
|
||||||
|
proxyType = fixInvalidProxyType(proxyType);
|
||||||
proxyAddr = ps.value("proxyAddr", proxyAddr).toString();
|
proxyAddr = ps.value("proxyAddr", proxyAddr).toString();
|
||||||
proxyPort = static_cast<quint16>(ps.value("proxyPort", proxyPort).toUInt());
|
proxyPort = static_cast<quint16>(ps.value("proxyPort", proxyPort).toUInt());
|
||||||
}
|
}
|
||||||
@ -2444,3 +2445,17 @@ Settings::friendProp& Settings::getOrInsertFriendPropRef(const ToxPk& id)
|
|||||||
|
|
||||||
return *it;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -578,6 +578,7 @@ private:
|
|||||||
Settings& operator=(const Settings&) = delete;
|
Settings& operator=(const Settings&) = delete;
|
||||||
void savePersonal(QString profileName, const ToxEncrypt* passkey);
|
void savePersonal(QString profileName, const ToxEncrypt* passkey);
|
||||||
friendProp& getOrInsertFriendPropRef(const ToxPk& id);
|
friendProp& getOrInsertFriendPropRef(const ToxPk& id);
|
||||||
|
ICoreSettings::ProxyType fixInvalidProxyType(ICoreSettings::ProxyType proxyType);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void savePersonal(Profile* profile);
|
void savePersonal(Profile* profile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user