mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-13 00:09:54 -05:00
block auto-reload and auto-save during merge confirmation
This commit is contained in:
parent
31bc5292a9
commit
a2af060432
@ -227,6 +227,7 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> db, QWidget* parent)
|
||||
connectDatabaseSignals();
|
||||
|
||||
m_blockAutoSave = false;
|
||||
m_blockAutoReload = false;
|
||||
|
||||
m_autosaveTimer = new QTimer(this);
|
||||
m_autosaveTimer->setSingleShot(true);
|
||||
@ -1191,6 +1192,10 @@ void DatabaseWidget::mergeDatabase(bool accepted)
|
||||
return;
|
||||
}
|
||||
|
||||
// block auto-reload and auto-save while merging
|
||||
m_blockAutoSave = true;
|
||||
m_blockAutoReload = true;
|
||||
|
||||
auto* mergeDialog = new MergeDialog(srcDb, m_db, this);
|
||||
connect(mergeDialog, &MergeDialog::databaseMerged, [this](bool changed) {
|
||||
if (changed) {
|
||||
@ -1216,6 +1221,10 @@ void DatabaseWidget::mergeDatabase(bool accepted)
|
||||
connect(mergeDialog, &MergeDialog::rejected, [this]() {
|
||||
showMessage(tr("Merge aborted - database was not modified."), MessageWidget::Information);
|
||||
});
|
||||
connect(mergeDialog, &MergeDialog::finished, [this](auto) {
|
||||
m_blockAutoSave = false;
|
||||
m_blockAutoReload = false;
|
||||
});
|
||||
mergeDialog->open();
|
||||
}
|
||||
|
||||
@ -1853,8 +1862,8 @@ bool DatabaseWidget::lock()
|
||||
|
||||
void DatabaseWidget::reloadDatabaseFile()
|
||||
{
|
||||
// Ignore reload if we are locked, saving, or currently editing an entry or group
|
||||
if (!m_db || isLocked() || isEntryEditActive() || isGroupEditActive() || isSaving()) {
|
||||
// Ignore reload if we are locked, saving, merging or currently editing an entry or group
|
||||
if (!m_db || m_blockAutoReload || isLocked() || isEntryEditActive() || isGroupEditActive() || isSaving()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1893,6 +1902,7 @@ void DatabaseWidget::reloadDatabaseFile()
|
||||
MessageBox::Merge);
|
||||
|
||||
if (result == MessageBox::Merge) {
|
||||
// TODO: use MergeDialog
|
||||
// Merge the old database into the new one
|
||||
Merger merger(m_db.data(), db.data());
|
||||
merger.merge();
|
||||
|
@ -318,6 +318,7 @@ private:
|
||||
|
||||
// Autoreload
|
||||
bool m_blockAutoSave;
|
||||
bool m_blockAutoReload;
|
||||
|
||||
// Autosave delay
|
||||
QPointer<QTimer> m_autosaveTimer;
|
||||
|
Loading…
Reference in New Issue
Block a user