tdf#117967 Fixes Save confirmation dialog for user cancel
The "Confirm save" dialog is launched from SfxMedium::CheckFileDate via "xHandler->handle( xInteractionRequestImpl );" and if the user canceled it the error is saved in the SfxMedium via "SetError(ERRCODE_ABORT);". Then, control is returned to the calling function SfxObjectShell::SaveTo_Impl which currently doesn't handle the cancel error condition, so this change just adds a check to detect it and return instead of doing more "save" processing. This return then goes to the calling function SfxObjectShell::DoSave_Impl which also does some save processing after cancel, in particular it updates the timestamps of the current SfxMedium (which are checked in SfxMedium::CheckFileDate from above and determines whether the "Confirm save" dialog will be launched), so this change prevents the updates to the timestamps by exiting early (i.e. before "DoSaveCompleted();" is called) if the abort error condition is seen so as to avoid a timestamp comparison result of equality which would prevent the "Confirm save" dialog from showing on every subsequent save action from the user. Now the behavior is for the timestamp comparison to fail equality (as would be expected if the file changed underneath the user) so as to ensure the "Confirm save" dialog continues to show for every subsequent save action by the user. Change-Id: I9c4aefc163a06029c80a8a28cdf4a09dff0031a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137540 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
This commit is contained in:
parent
4531236933
commit
07250a8327
1 changed files with 18 additions and 1 deletions
|
@ -1229,7 +1229,15 @@ bool SfxObjectShell::SaveTo_Impl
|
|||
bStoreToSameLocation = true;
|
||||
|
||||
if ( pMedium->DocNeedsFileDateCheck() )
|
||||
{
|
||||
rMedium.CheckFileDate( pMedium->GetInitFileDate( false ) );
|
||||
if (rMedium.GetErrorCode() == ERRCODE_ABORT)
|
||||
{
|
||||
// if user cancels the save, exit early to avoid resetting SfxMedium values that
|
||||
// would cause an invalid subsequent filedate check
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// before we overwrite the original file, we will make a backup if there is a demand for that
|
||||
// if the backup is not created here it will be created internally and will be removed in case of successful saving
|
||||
|
@ -2616,7 +2624,16 @@ bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs )
|
|||
else
|
||||
{
|
||||
// transfer error code from medium to objectshell
|
||||
SetError(pMediumTmp->GetError());
|
||||
ErrCode errCode = pMediumTmp->GetError();
|
||||
SetError(errCode);
|
||||
|
||||
if (errCode == ERRCODE_ABORT)
|
||||
{
|
||||
// avoid doing DoSaveCompleted() which updates the SfxMedium timestamp values
|
||||
// and prevents subsequent filedate checks from being accurate
|
||||
delete pMediumTmp;
|
||||
return false;
|
||||
}
|
||||
|
||||
// reconnect to object storage
|
||||
DoSaveCompleted();
|
||||
|
|
Loading…
Reference in a new issue