mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-28 08:49:42 -05:00
Detect and display more errors when writing databases.
This commit is contained in:
parent
0422943d52
commit
606e36acf3
@ -295,24 +295,24 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
|
|||||||
DatabaseManagerStruct& dbStruct = m_dbList[db];
|
DatabaseManagerStruct& dbStruct = m_dbList[db];
|
||||||
|
|
||||||
if (dbStruct.saveToFilename) {
|
if (dbStruct.saveToFilename) {
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
QSaveFile saveFile(dbStruct.filePath);
|
QSaveFile saveFile(dbStruct.filePath);
|
||||||
if (saveFile.open(QIODevice::WriteOnly)) {
|
if (saveFile.open(QIODevice::WriteOnly)) {
|
||||||
m_writer.writeDatabase(&saveFile, db);
|
m_writer.writeDatabase(&saveFile, db);
|
||||||
result = saveFile.commit();
|
if (m_writer.hasError()) {
|
||||||
|
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||||
|
+ m_writer.errorString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!saveFile.commit()) {
|
||||||
|
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||||
|
+ saveFile.errorString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
dbStruct.modified = false;
|
||||||
dbStruct.modified = false;
|
updateTabName(db);
|
||||||
updateTabName(db);
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
|
||||||
+ saveFile.errorString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return saveDatabaseAs(db);
|
return saveDatabaseAs(db);
|
||||||
@ -370,6 +370,11 @@ bool DatabaseTabWidget::saveDatabaseAs(Database* db)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_writer.writeDatabase(&saveFile, db);
|
m_writer.writeDatabase(&saveFile, db);
|
||||||
|
if (m_writer.hasError()) {
|
||||||
|
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||||
|
+ m_writer.errorString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!saveFile.commit()) {
|
if (!saveFile.commit()) {
|
||||||
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||||
+ saveFile.errorString());
|
+ saveFile.errorString());
|
||||||
|
Loading…
Reference in New Issue
Block a user