From 8a3d4d38573fcf867fdf1409cb5a17eacd87f741 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Thu, 1 Mar 2018 22:03:53 +0100 Subject: [PATCH] proxy: Actually fix settings migration logic Not sure what the previous code was supposed to accomplish, but proxy settings are stored in [CoreAccounts] and thus migration needs to happen for each configured account. Also, the UseProxy flag was removed and thus must be translated to ProxyType::NoProxy. Closes GH-181. --- src/qtui/qtuiapplication.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/qtui/qtuiapplication.cpp b/src/qtui/qtuiapplication.cpp index 05ffeed9..927248f4 100644 --- a/src/qtui/qtuiapplication.cpp +++ b/src/qtui/qtuiapplication.cpp @@ -281,12 +281,17 @@ bool QtUiApplication::applySettingsMigration(QtUiSettings settings, const uint n // migrateSettings()! Otherwise, your upgrade logic won't ever be called. case 7: { - // New default changes: ProxyType=3 (no proxy) now means QNetworkProxy::HttpProxy - // So we have to change it to ProxyType=2 (QNetworkProxy::NoProxy) - const QString proxyType = "ProxyType"; - if (settings.valueExists(proxyType) && settings.value(proxyType)=="3") { - settings.setValue(proxyType, 2); + // New default changes: UseProxy is no longer used in CoreAccountSettings + CoreAccountSettings s; + for (auto &&accountId : s.knownAccounts()) { + auto map = s.retrieveAccountData(accountId); + if (!map.value("UseProxy", false).toBool()) { + map["ProxyType"] = static_cast(QNetworkProxy::ProxyType::NoProxy); + } + map.remove("UseProxy"); + s.storeAccountData(accountId, map); } + // Migration complete! return true; } -- 2.20.1