diff options
author | Justin Luth <jluth@mail.com> | 2023-08-08 09:41:48 -0400 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-08-09 12:13:44 +0200 |
commit | 90b23d0b4528a12ababa3c2897ab3f1a3719b2f1 (patch) | |
tree | 5e9c19149d84f31fc8832a39f8691da282673178 /framework/source | |
parent | 13eb63f377f46a61bc763ab0f40eb6769dcefbb8 (diff) |
tdf#144512 autorecovery: always wait for user idle with timed save
Only the "active" document was waiting for a user idle.
But that doesn't make sense because the background apps
still lock the foreground app during file save.
So all timed backups should wait for a user idle period
before starting their recovery / autosave.
Once an idle loop is triggered, no autosave will ever run again
until an idle timeout occurs! So a busy user who switches from
one doc to another without ever pausing still wouldn't ever
get a backup - even from the background docs!
Without this patch, only the first modified documents
(if backgrounded within 10 minutes) would ever
get a recovery save. So in pretty much every case
this patch makes sense AFAICS.
Change-Id: I6e9e04aa2e50895e53826b427cb52c129da43701
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155459
Reviewed-by: Justin Luth <jluth@mail.com>
Tested-by: Jenkins
Diffstat (limited to 'framework/source')
-rw-r--r-- | framework/source/services/autorecovery.cxx | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index b4e898952aad..48c8978c9ab1 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -2840,17 +2840,8 @@ AutoRecovery::ETimerType AutoRecovery::implts_saveDocs( bool bAllow if (pParams) xExternalProgress = pParams->m_xProgress; - css::uno::Reference< css::frame::XDesktop2 > xDesktop = css::frame::Desktop::create(m_xContext); OUString sBackupPath(SvtPathOptions().GetBackupPath()); - css::uno::Reference< css::frame::XController > xActiveController; - css::uno::Reference< css::frame::XModel > xActiveModel; - css::uno::Reference< css::frame::XFrame > xActiveFrame = xDesktop->getActiveFrame(); - if (xActiveFrame.is()) - xActiveController = xActiveFrame->getController(); - if (xActiveController.is()) - xActiveModel = xActiveController->getModel(); - // Set the default timer action for our call. // Default = NORMAL_AUTOSAVE // We return a suggestion for an active timer only. @@ -2967,37 +2958,27 @@ AutoRecovery::ETimerType AutoRecovery::implts_saveDocs( bool bAllow } } - // a) Document was not postponed - and is active now. => postpone it (restart timer, restart loop) - // b) Document was not postponed - and is not active now. => save it - // c) Document was postponed - and is not active now. => save it - // d) Document was postponed - and is active now. => save it (because user idle was checked already) - bool bActive = (xActiveModel == aInfo.Document); - bool bWasPostponed = ((aInfo.DocumentState & DocState::Postponed) == DocState::Postponed); - - if ( - ! bWasPostponed && - bActive - ) + // a) Document was not postponed => wait for user idle if not urgent + // b) Document was postponed => save it (because user idle/call_back was checked already) + if (!(aInfo.DocumentState & DocState::Postponed)) { aInfo.DocumentState |= DocState::Postponed; *pIt = aInfo; // postponed documents will be saved if this method is called again! // That can be done by an outside started timer => E_POLL_FOR_USER_IDLE (if normal AutoSave is active) // or it must be done directly without starting any timer => E_CALL_ME_BACK (if Emergency- or SessionSave is active and must be finished ASAP!) - eTimer = AutoRecovery::E_POLL_FOR_USER_IDLE; if (!bAllowUserIdleLoop) eTimer = AutoRecovery::E_CALL_ME_BACK; + else + eTimer = AutoRecovery::E_POLL_FOR_USER_IDLE; continue; } - // b, c, d) - // } /* SAFE */ g.clear(); // changing of aInfo and flushing it is done inside implts_saveOneDoc! implts_saveOneDoc(sBackupPath, aInfo, xExternalProgress); implts_informListener(eJob, AutoRecovery::implst_createFeatureStateEvent(eJob, OPERATION_UPDATE, &aInfo)); g.reset(); - // /* SAFE */ { *pIt = aInfo; } @@ -3009,13 +2990,11 @@ AutoRecovery::ETimerType AutoRecovery::implts_saveDocs( bool bAllow pIt = dangerousDoc; AutoRecovery::TDocumentInfo aInfo = *pIt; - // } /* SAFE */ g.clear(); // changing of aInfo and flushing it is done inside implts_saveOneDoc! implts_saveOneDoc(sBackupPath, aInfo, xExternalProgress); implts_informListener(eJob, AutoRecovery::implst_createFeatureStateEvent(eJob, OPERATION_UPDATE, &aInfo)); g.reset(); - // /* SAFE */ { *pIt = aInfo; } |