summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2014-03-14 10:19:23 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-03-14 10:49:53 -0700
commitb5d0cfd557aa94a423e19663339439301ab1a5ae (patch)
treefbc7743cdac57ea0f779bca3918aa23dc073f609 /qt-ui
parent76d4e3d91614459394b1909d625adc7219b04740 (diff)
downloadsubsurface-b5d0cfd557aa94a423e19663339439301ab1a5ae.tar.gz
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>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/mainwindow.cpp29
-rw-r--r--qt-ui/mainwindow.h4
2 files changed, 19 insertions, 14 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index b67de1588..671f39cf7 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -882,7 +882,7 @@ void MainWindow::recentFileTriggered(bool checked)
loadFiles(QStringList() << filename);
}
-void MainWindow::file_save_as(void)
+int MainWindow::file_save_as(void)
{
QString filename;
const char *default_filename;
@@ -893,20 +893,23 @@ void MainWindow::file_save_as(void)
default_filename = prefs.default_filename;
filename = QFileDialog::getSaveFileName(this, tr("Save File as"), default_filename,
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())
- ui.InfoWidget->acceptChanges();
+ if (ui.InfoWidget->isEditing())
+ ui.InfoWidget->acceptChanges();
- save_dives(filename.toUtf8().data());
- set_filename(filename.toUtf8().data(), true);
- setTitle(MWTF_FILENAME);
- mark_divelist_changed(false);
- addRecentFile(QStringList() << filename);
- }
+ if (save_dives(filename.toUtf8().data()))
+ return -1;
+
+ set_filename(filename.toUtf8().data(), true);
+ 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;
@@ -924,9 +927,11 @@ void MainWindow::file_save(void)
if (!current_def_dir.exists())
current_def_dir.mkpath(current_def_dir.absolutePath());
}
- save_dives(existing_filename);
+ if (save_dives(existing_filename))
+ return -1;
mark_divelist_changed(false);
addRecentFile(QStringList() << QString(existing_filename));
+ return 0;
}
void MainWindow::showError(QString message)
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 8244d0a0f..971bd1768 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -163,8 +163,8 @@ private:
static MainWindow *m_Instance;
bool askSaveChanges();
void writeSettings();
- void file_save();
- void file_save_as();
+ int file_save();
+ int file_save_as();
void beginChangeState(CurrentState s);
void saveSplitterSizes();
QString lastUsedDir();