mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
propagate save errors further, don't mark divelist unchanged
This at least avoids marking the dive list as unchanged on a failed write, and propagates the error further up the stack. We still don't show the error string in the GUI, though. I'll start doing that next, I think. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
76d4e3d916
commit
b5d0cfd557
2 changed files with 19 additions and 14 deletions
|
@ -882,7 +882,7 @@ void MainWindow::recentFileTriggered(bool checked)
|
||||||
loadFiles(QStringList() << filename);
|
loadFiles(QStringList() << filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::file_save_as(void)
|
int MainWindow::file_save_as(void)
|
||||||
{
|
{
|
||||||
QString filename;
|
QString filename;
|
||||||
const char *default_filename;
|
const char *default_filename;
|
||||||
|
@ -893,20 +893,23 @@ void MainWindow::file_save_as(void)
|
||||||
default_filename = prefs.default_filename;
|
default_filename = prefs.default_filename;
|
||||||
filename = QFileDialog::getSaveFileName(this, tr("Save File as"), default_filename,
|
filename = QFileDialog::getSaveFileName(this, tr("Save File as"), default_filename,
|
||||||
tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
|
tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
|
||||||
if (!filename.isNull() && !filename.isEmpty()) {
|
if (filename.isNull() || filename.isEmpty())
|
||||||
|
return report_error("No filename to save into");
|
||||||
|
|
||||||
if (ui.InfoWidget->isEditing())
|
if (ui.InfoWidget->isEditing())
|
||||||
ui.InfoWidget->acceptChanges();
|
ui.InfoWidget->acceptChanges();
|
||||||
|
|
||||||
save_dives(filename.toUtf8().data());
|
if (save_dives(filename.toUtf8().data()))
|
||||||
set_filename(filename.toUtf8().data(), true);
|
return -1;
|
||||||
setTitle(MWTF_FILENAME);
|
|
||||||
mark_divelist_changed(false);
|
set_filename(filename.toUtf8().data(), true);
|
||||||
addRecentFile(QStringList() << filename);
|
setTitle(MWTF_FILENAME);
|
||||||
}
|
mark_divelist_changed(false);
|
||||||
|
addRecentFile(QStringList() << filename);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::file_save(void)
|
int MainWindow::file_save(void)
|
||||||
{
|
{
|
||||||
const char *current_default;
|
const char *current_default;
|
||||||
|
|
||||||
|
@ -924,9 +927,11 @@ void MainWindow::file_save(void)
|
||||||
if (!current_def_dir.exists())
|
if (!current_def_dir.exists())
|
||||||
current_def_dir.mkpath(current_def_dir.absolutePath());
|
current_def_dir.mkpath(current_def_dir.absolutePath());
|
||||||
}
|
}
|
||||||
save_dives(existing_filename);
|
if (save_dives(existing_filename))
|
||||||
|
return -1;
|
||||||
mark_divelist_changed(false);
|
mark_divelist_changed(false);
|
||||||
addRecentFile(QStringList() << QString(existing_filename));
|
addRecentFile(QStringList() << QString(existing_filename));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showError(QString message)
|
void MainWindow::showError(QString message)
|
||||||
|
|
|
@ -163,8 +163,8 @@ private:
|
||||||
static MainWindow *m_Instance;
|
static MainWindow *m_Instance;
|
||||||
bool askSaveChanges();
|
bool askSaveChanges();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
void file_save();
|
int file_save();
|
||||||
void file_save_as();
|
int file_save_as();
|
||||||
void beginChangeState(CurrentState s);
|
void beginChangeState(CurrentState s);
|
||||||
void saveSplitterSizes();
|
void saveSplitterSizes();
|
||||||
QString lastUsedDir();
|
QString lastUsedDir();
|
||||||
|
|
Loading…
Add table
Reference in a new issue