mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
1206da2b05
commit
dd9524085f
|
@ -18,11 +18,33 @@
|
|||
*/
|
||||
|
||||
#include "personalsettingsupgrader.h"
|
||||
#include "settingsserializer.h"
|
||||
#include "src/core/toxpk.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace {
|
||||
bool version0to1(SettingsSerializer& ps)
|
||||
{
|
||||
ps.beginGroup("Friends");
|
||||
{
|
||||
int size = ps.beginReadArray("Friend");
|
||||
for (int i = 0; i < size; i++) {
|
||||
ps.setArrayIndex(i);
|
||||
const auto oldFriendAddr = ps.value("addr").toString();
|
||||
auto newFriendAddr = oldFriendAddr.left(ToxPk::numHexChars);
|
||||
ps.setValue("addr", newFriendAddr);
|
||||
}
|
||||
ps.endArray();
|
||||
}
|
||||
ps.endGroup();
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool PersonalSettingsUpgrader::doUpgrade(SettingsSerializer& settingsSerializer, int fromVer, int toVer)
|
||||
{
|
||||
if (fromVer == toVer) {
|
||||
|
@ -37,7 +59,7 @@ bool PersonalSettingsUpgrader::doUpgrade(SettingsSerializer& settingsSerializer,
|
|||
}
|
||||
|
||||
using SettingsUpgradeFn = bool (*)(SettingsSerializer&);
|
||||
std::vector<SettingsUpgradeFn> upgradeFns = {};
|
||||
std::vector<SettingsUpgradeFn> upgradeFns = {version0to1};
|
||||
|
||||
assert(fromVer < static_cast<int>(upgradeFns.size()));
|
||||
assert(toVer == static_cast<int>(upgradeFns.size()));
|
||||
|
|
|
@ -65,7 +65,7 @@ Settings* Settings::settings{nullptr};
|
|||
CompatibleRecursiveMutex Settings::bigLock;
|
||||
QThread* Settings::settingsThread{nullptr};
|
||||
static constexpr int GLOBAL_SETTINGS_VERSION = 1;
|
||||
static constexpr int PERSONAL_SETTINGS_VERSION = 0;
|
||||
static constexpr int PERSONAL_SETTINGS_VERSION = 1;
|
||||
|
||||
Settings::Settings()
|
||||
: loaded(false)
|
||||
|
|
Loading…
Reference in New Issue
Block a user