mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Constify strings in pref.h
Make all char * pointers in pref.h const to make it clear that these strings are not mutable. This meant adding a number of (void *) casts in calls to free(). Apart from being the right thing to do, this commit makes the code more consistent, as many of the strings in pref.h were already const. While touching core/qthelper.cpp turn three instances of (void*) into (void *). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f8fcd65bc4
commit
6ae16b87d0
6 changed files with 59 additions and 58 deletions
|
@ -383,7 +383,7 @@ void QMLManager::saveCloudCredentials()
|
|||
s.setValue("cloud_verification_status", credentialStatus());
|
||||
s.sync();
|
||||
if (!same_string(prefs.cloud_storage_email, qPrintable(cloudUser))) {
|
||||
free(prefs.cloud_storage_email);
|
||||
free((void *)prefs.cloud_storage_email);
|
||||
prefs.cloud_storage_email = strdup(qPrintable(cloudUser));
|
||||
cloudCredentialsChanged = true;
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ void QMLManager::saveCloudCredentials()
|
|||
}
|
||||
|
||||
if (!same_string(prefs.cloud_storage_password, qPrintable(cloudPwd))) {
|
||||
free(prefs.cloud_storage_password);
|
||||
free((void *)prefs.cloud_storage_password);
|
||||
prefs.cloud_storage_password = strdup(qPrintable(cloudPwd));
|
||||
}
|
||||
if (cloudUser.isEmpty() || cloudPwd.isEmpty()) {
|
||||
|
@ -404,7 +404,7 @@ void QMLManager::saveCloudCredentials()
|
|||
} else if (cloudCredentialsChanged) {
|
||||
// let's make sure there are no unsaved changes
|
||||
saveChangesLocal();
|
||||
free(prefs.userid);
|
||||
free((void *)prefs.userid);
|
||||
prefs.userid = NULL;
|
||||
syncLoadFromCloud();
|
||||
QString url;
|
||||
|
@ -550,7 +550,7 @@ void QMLManager::retrieveUserid()
|
|||
}
|
||||
if (!userid.isEmpty()) {
|
||||
// overwrite the existing userid
|
||||
free(prefs.userid);
|
||||
free((void *)prefs.userid);
|
||||
prefs.userid = strdup(qPrintable(userid));
|
||||
QSettings s;
|
||||
s.setValue("subsurface_webservice_uid", prefs.userid);
|
||||
|
@ -649,9 +649,9 @@ void QMLManager::revertToNoCloudIfNeeded()
|
|||
appendTextToLog(QStringLiteral("taking things back offline since sync with cloud failed"));
|
||||
prefs.git_local_only = syncToCloud();
|
||||
}
|
||||
free(prefs.cloud_storage_email);
|
||||
free((void *)prefs.cloud_storage_email);
|
||||
prefs.cloud_storage_email = NULL;
|
||||
free(prefs.cloud_storage_password);
|
||||
free((void *)prefs.cloud_storage_password);
|
||||
prefs.cloud_storage_password = NULL;
|
||||
setCloudUserName("");
|
||||
setCloudPassword("");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue