From 19871a6ab2c7a3022e0f7981154d4d6cd59715a9 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Tue, 24 Jul 2018 21:33:11 +0200 Subject: core: qPrefCloudStorage save userid to new location userid was saved outside all groups, even though it belongs to cloudStorage Add code to save in new location and read from new/old location Signed-off-by: Jan Iversen --- core/settings/qPrefCloudStorage.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/core/settings/qPrefCloudStorage.cpp b/core/settings/qPrefCloudStorage.cpp index 0eccb616c..3455aaf2d 100644 --- a/core/settings/qPrefCloudStorage.cpp +++ b/core/settings/qPrefCloudStorage.cpp @@ -108,10 +108,16 @@ HANDLE_PREFERENCE_BOOL(CloudStorage, "/save_userid_local", save_userid_local); SET_PREFERENCE_TXT(CloudStorage, userid); void qPrefCloudStorage::disk_userid(bool doSync) { - //WARNING: UserId is stored outside of any group, but it belongs to Cloud Storage. - const QString group = QStringLiteral(""); - if (doSync) + if (doSync) { + // always save in new position (part of cloud storage group) qPrefPrivate::instance()->setting.setValue(group + "subsurface_webservice_uid", prefs.userid); - else - prefs.userid = copy_qstring(qPrefPrivate::instance()->setting.value(group + "subsurface_webservice_uid", default_prefs.userid).toString()); + } else { + //WARNING: UserId was stored outside of any group. + // try to read from new location, if it fails read from old location + prefs.userid = copy_qstring(qPrefPrivate::instance()->setting.value(group + "subsurface_webservice_uid", "NoUserIdHere").toString()); + if (QString(prefs.userid) == "NoUserIdHere") { + const QString group = QStringLiteral(""); + prefs.userid = copy_qstring(qPrefPrivate::instance()->setting.value(group + "subsurface_webservice_uid", default_prefs.userid).toString()); + } + } } -- cgit v1.2.3-70-g09d2