Skip to content

Commit

Permalink
Display an error message when opening the database fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
debfx authored and droidmonkey committed Sep 30, 2016
1 parent ba68e0a commit 3415073
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/gui/DatabaseOpenWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ void DatabaseOpenWidget::openDatabase()

QFile file(m_filename);
if (!file.open(QIODevice::ReadOnly)) {
// TODO: error message
MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n")
.append(file.errorString()));
return;
}
if (m_db) {
Expand Down
3 changes: 2 additions & 1 deletion src/gui/DatabaseRepairWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ void DatabaseRepairWidget::openDatabase()

QFile file(m_filename);
if (!file.open(QIODevice::ReadOnly)) {
// TODO: error message
MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n")
.append(file.errorString()));
Q_EMIT editFinished(false);
return;
}
Expand Down
5 changes: 2 additions & 3 deletions src/gui/DatabaseTabWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,10 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw,

// test if we can read/write or read the file
QFile file(fileName);
// TODO: error handling
if (!file.open(QIODevice::ReadWrite)) {
if (!file.open(QIODevice::ReadOnly)) {
// can't open
// TODO: error message
MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n")
.append(file.errorString()));
return;
}
else {
Expand Down
3 changes: 2 additions & 1 deletion src/gui/KeePass1OpenWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ void KeePass1OpenWidget::openDatabase()

QFile file(m_filename);
if (!file.open(QIODevice::ReadOnly)) {
// TODO: error message
MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n")
.append(file.errorString()));
return;
}
if (m_db) {
Expand Down

0 comments on commit 3415073

Please sign in to comment.