mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-27 00:09:53 -05:00
Corrected database corruption when locked [#1113]
This commit is contained in:
parent
7ef61b47e3
commit
e17b3d24bf
@ -298,8 +298,7 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
||||
if (!saveDatabase(db)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else if (dbStruct.dbWidget->currentMode() != DatabaseWidget::LockedMode) {
|
||||
QMessageBox::StandardButton result =
|
||||
MessageBox::question(
|
||||
this, tr("Save changes?"),
|
||||
@ -309,8 +308,7 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
||||
if (!saveDatabase(db)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (result == QMessageBox::Cancel) {
|
||||
} else if (result == QMessageBox::Cancel) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -355,8 +353,13 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
|
||||
{
|
||||
DatabaseManagerStruct& dbStruct = m_dbList[db];
|
||||
|
||||
if (dbStruct.saveToFilename) {
|
||||
if (dbStruct.dbWidget->currentMode() == DatabaseWidget::LockedMode) {
|
||||
// Never allow saving a locked database; it causes corruption
|
||||
// We return true since a save is not required
|
||||
return true;
|
||||
}
|
||||
|
||||
if (dbStruct.saveToFilename) {
|
||||
dbStruct.dbWidget->blockAutoReload(true);
|
||||
QString errorMessage = db->saveToFile(dbStruct.canonicalFilePath);
|
||||
dbStruct.dbWidget->blockAutoReload(false);
|
||||
@ -375,7 +378,6 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
|
||||
MessageWidget::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
return saveDatabaseAs(db);
|
||||
}
|
||||
|
@ -1125,7 +1125,7 @@ void DatabaseWidget::onWatchedFileChanged()
|
||||
|
||||
void DatabaseWidget::reloadDatabaseFile()
|
||||
{
|
||||
if (m_db == nullptr)
|
||||
if (m_db == nullptr || currentMode() == DatabaseWidget::LockedMode)
|
||||
return;
|
||||
|
||||
if (! config()->get("AutoReloadOnChange").toBool()) {
|
||||
|
Loading…
Reference in New Issue
Block a user