1
0
Fork 0
mirror of https://github.com/subsurface/subsurface.git synced 2025-02-19 22:16:15 +00:00

Remove second parameter (bool force) in set_filename()

The last force=false case was removed in commit 96d1cc570e.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2017-12-10 22:22:13 +01:00 committed by Lubomir I. Ivanov
parent fa469aa86c
commit ea0cbba804
5 changed files with 16 additions and 18 deletions

View file

@ -723,7 +723,7 @@ extern int match_one_dc(struct divecomputer *a, struct divecomputer *b);
extern void parse_xml_init(void); extern void parse_xml_init(void);
extern int parse_xml_buffer(const char *url, const char *buf, int size, struct dive_table *table, const char **params); extern int parse_xml_buffer(const char *url, const char *buf, int size, struct dive_table *table, const char **params);
extern void parse_xml_exit(void); extern void parse_xml_exit(void);
extern void set_filename(const char *filename, bool force); extern void set_filename(const char *filename);
extern int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table); extern int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table);
extern int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table); extern int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table);

View file

@ -560,10 +560,8 @@ QLocale getLocale()
return loc; return loc;
} }
void set_filename(const char *filename, bool force) void set_filename(const char *filename)
{ {
if (!force && existing_filename)
return;
free((void *)existing_filename); free((void *)existing_filename);
if (filename) if (filename)
existing_filename = strdup(filename); existing_filename = strdup(filename);

View file

@ -611,7 +611,7 @@ void MainWindow::on_actionCloudstorageopen_triggered()
showProgressBar(); showProgressBar();
QByteArray fileNamePtr = QFile::encodeName(filename); QByteArray fileNamePtr = QFile::encodeName(filename);
if (!parse_file(fileNamePtr.data())) { if (!parse_file(fileNamePtr.data())) {
set_filename(fileNamePtr.data(), true); set_filename(fileNamePtr.data());
setTitle(MWTF_FILENAME); setTitle(MWTF_FILENAME);
} }
getNotificationWidget()->hideNotification(); getNotificationWidget()->hideNotification();
@ -642,7 +642,7 @@ void MainWindow::on_actionCloudstoragesave_triggered()
if (error) if (error)
return; return;
set_filename(filename.toUtf8().data(), true); set_filename(filename.toUtf8().data());
setTitle(MWTF_FILENAME); setTitle(MWTF_FILENAME);
mark_divelist_changed(false); mark_divelist_changed(false);
} }
@ -1655,7 +1655,7 @@ int MainWindow::file_save_as(void)
if (save_dives(filename.toUtf8().data())) if (save_dives(filename.toUtf8().data()))
return -1; return -1;
set_filename(filename.toUtf8().data(), true); set_filename(filename.toUtf8().data());
setTitle(MWTF_FILENAME); setTitle(MWTF_FILENAME);
mark_divelist_changed(false); mark_divelist_changed(false);
addRecentFile(filename, true); addRecentFile(filename, true);
@ -1801,7 +1801,7 @@ void MainWindow::loadFiles(const QStringList fileNames)
for (int i = 0; i < fileNames.size(); ++i) { for (int i = 0; i < fileNames.size(); ++i) {
fileNamePtr = QFile::encodeName(fileNames.at(i)); fileNamePtr = QFile::encodeName(fileNames.at(i));
if (!parse_file(fileNamePtr.data())) { if (!parse_file(fileNamePtr.data())) {
set_filename(fileNamePtr.data(), true); set_filename(fileNamePtr.data());
addRecentFile(fileNamePtr, false); addRecentFile(fileNamePtr, false);
setTitle(MWTF_FILENAME); setTitle(MWTF_FILENAME);
} }

View file

@ -240,7 +240,7 @@ void QMLManager::openLocalThenRemote(QString url)
prefs.git_local_only = false; prefs.git_local_only = false;
appendTextToLog(QStringLiteral("taking things online to be able to switch to cloud account")); appendTextToLog(QStringLiteral("taking things online to be able to switch to cloud account"));
} }
set_filename(fileNamePrt.data(), true); set_filename(fileNamePrt.data());
if (prefs.git_local_only) { if (prefs.git_local_only) {
appendTextToLog(QStringLiteral("have cloud credentials, but user asked not to connect to network")); appendTextToLog(QStringLiteral("have cloud credentials, but user asked not to connect to network"));
alreadySaving = false; alreadySaving = false;
@ -318,7 +318,7 @@ void QMLManager::finishSetup()
// we got an error loading the local file // we got an error loading the local file
appendTextToLog(QString("got error %2 when parsing file %1").arg(existing_filename, get_error_string())); appendTextToLog(QString("got error %2 when parsing file %1").arg(existing_filename, get_error_string()));
setNotificationText(tr("Error parsing local storage, giving up")); setNotificationText(tr("Error parsing local storage, giving up"));
set_filename(NULL, true); set_filename(NULL);
} else { } else {
// successfully opened the local file, now add thigs to the dive list // successfully opened the local file, now add thigs to the dive list
consumeFinishedLoad(0); consumeFinishedLoad(0);
@ -596,7 +596,7 @@ void QMLManager::loadDivesWithValidCredentials()
report_error("filename is now %s", fileNamePrt.data()); report_error("filename is now %s", fileNamePrt.data());
QString errorString(get_error_string()); QString errorString(get_error_string());
appendTextToLog(errorString); appendTextToLog(errorString);
set_filename(fileNamePrt.data(), true); set_filename(fileNamePrt.data());
} else { } else {
report_error("failed to open file %s", fileNamePrt.data()); report_error("failed to open file %s", fileNamePrt.data());
QString errorString(get_error_string()); QString errorString(get_error_string());
@ -657,7 +657,7 @@ void QMLManager::revertToNoCloudIfNeeded()
setCloudUserName(""); setCloudUserName("");
setCloudPassword(""); setCloudPassword("");
setCredentialStatus(CS_NOCLOUD); setCredentialStatus(CS_NOCLOUD);
set_filename(NOCLOUD_LOCALSTORAGE, true); set_filename(NOCLOUD_LOCALSTORAGE);
setStartPageText(RED_FONT + tr("Failed to connect to cloud server, reverting to no cloud status") + END_FONT); setStartPageText(RED_FONT + tr("Failed to connect to cloud server, reverting to no cloud status") + END_FONT);
} }
alreadySaving = false; alreadySaving = false;
@ -1099,7 +1099,7 @@ void QMLManager::openNoCloudRepo()
if (git == dummy_git_repository) { if (git == dummy_git_repository) {
if (git_create_local_repo(filename)) if (git_create_local_repo(filename))
appendTextToLog(get_error_string()); appendTextToLog(get_error_string());
set_filename(filename, true); set_filename(filename);
GeneralSettingsObjectWrapper s(this); GeneralSettingsObjectWrapper s(this);
s.setDefaultFilename(filename); s.setDefaultFilename(filename);
s.setDefaultFileBehavior(LOCAL_DEFAULT_FILE); s.setDefaultFileBehavior(LOCAL_DEFAULT_FILE);
@ -1116,7 +1116,7 @@ void QMLManager::saveChangesLocal()
char *filename = NOCLOUD_LOCALSTORAGE; char *filename = NOCLOUD_LOCALSTORAGE;
if (git_create_local_repo(filename)) if (git_create_local_repo(filename))
appendTextToLog(get_error_string()); appendTextToLog(get_error_string());
set_filename(filename, true); set_filename(filename);
GeneralSettingsObjectWrapper s(this); GeneralSettingsObjectWrapper s(this);
s.setDefaultFilename(filename); s.setDefaultFilename(filename);
s.setDefaultFileBehavior(LOCAL_DEFAULT_FILE); s.setDefaultFileBehavior(LOCAL_DEFAULT_FILE);
@ -1138,7 +1138,7 @@ void QMLManager::saveChangesLocal()
QString errorString(get_error_string()); QString errorString(get_error_string());
appendTextToLog(errorString); appendTextToLog(errorString);
setNotificationText(errorString); setNotificationText(errorString);
set_filename(NULL, true); set_filename(NULL);
prefs.git_local_only = glo; prefs.git_local_only = glo;
alreadySaving = false; alreadySaving = false;
return; return;
@ -1481,7 +1481,7 @@ void QMLManager::setCredentialStatus(const cloud_status_qml value)
setOldStatus(m_credentialStatus); setOldStatus(m_credentialStatus);
if (value == CS_NOCLOUD) { if (value == CS_NOCLOUD) {
appendTextToLog("Switching to no cloud mode"); appendTextToLog("Switching to no cloud mode");
set_filename(NOCLOUD_LOCALSTORAGE, true); set_filename(NOCLOUD_LOCALSTORAGE);
clearCredentials(); clearCredentials();
} }
m_credentialStatus = value; m_credentialStatus = value;

View file

@ -52,9 +52,9 @@ int main(int argc, char **argv)
taglist_init_global(); taglist_init_global();
init_ui(); init_ui();
if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE) if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE)
set_filename(prefs.default_filename, true); set_filename(prefs.default_filename);
else else
set_filename(NULL, true); set_filename(NULL);
// some hard coded settings // some hard coded settings
prefs.animation_speed = 0; // we render the profile to pixmap, no animations prefs.animation_speed = 0; // we render the profile to pixmap, no animations