mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-14 00:39: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)) {
|
if (!saveDatabase(db)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else if (dbStruct.dbWidget->currentMode() != DatabaseWidget::LockedMode) {
|
||||||
else {
|
|
||||||
QMessageBox::StandardButton result =
|
QMessageBox::StandardButton result =
|
||||||
MessageBox::question(
|
MessageBox::question(
|
||||||
this, tr("Save changes?"),
|
this, tr("Save changes?"),
|
||||||
@ -307,10 +306,9 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
|||||||
QMessageBox::Yes | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Yes);
|
QMessageBox::Yes | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Yes);
|
||||||
if (result == QMessageBox::Yes) {
|
if (result == QMessageBox::Yes) {
|
||||||
if (!saveDatabase(db)) {
|
if (!saveDatabase(db)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else if (result == QMessageBox::Cancel) {
|
||||||
else if (result == QMessageBox::Cancel) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -355,8 +353,13 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
|
|||||||
{
|
{
|
||||||
DatabaseManagerStruct& dbStruct = m_dbList[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);
|
dbStruct.dbWidget->blockAutoReload(true);
|
||||||
QString errorMessage = db->saveToFile(dbStruct.canonicalFilePath);
|
QString errorMessage = db->saveToFile(dbStruct.canonicalFilePath);
|
||||||
dbStruct.dbWidget->blockAutoReload(false);
|
dbStruct.dbWidget->blockAutoReload(false);
|
||||||
@ -375,7 +378,6 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
|
|||||||
MessageWidget::Error);
|
MessageWidget::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return saveDatabaseAs(db);
|
return saveDatabaseAs(db);
|
||||||
}
|
}
|
||||||
|
@ -1125,7 +1125,7 @@ void DatabaseWidget::onWatchedFileChanged()
|
|||||||
|
|
||||||
void DatabaseWidget::reloadDatabaseFile()
|
void DatabaseWidget::reloadDatabaseFile()
|
||||||
{
|
{
|
||||||
if (m_db == nullptr)
|
if (m_db == nullptr || currentMode() == DatabaseWidget::LockedMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (! config()->get("AutoReloadOnChange").toBool()) {
|
if (! config()->get("AutoReloadOnChange").toBool()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user