[Libreoffice-commits] core.git: sfx2/source
Mike Kaganski
mike.kaganski at collabora.com
Wed Jul 11 10:12:33 UTC 2018
sfx2/source/doc/objstor.cxx | 43 ++++++++++++++++++++++++++++++++-----------
1 file changed, 32 insertions(+), 11 deletions(-)
New commits:
commit f61304db5118082a2d35b57fa374af37c0430d64
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date: Wed Jul 11 08:54:41 2018 +0200
Make sure to re-enable UI after save
Change-Id: I9e8ea29893b372daa27262b2224481c67b4e4482
Reviewed-on: https://gerrit.libreoffice.org/57258
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 5bc9da2d76dd..d594da1b51fb 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1072,18 +1072,40 @@ bool SfxObjectShell::DoSave()
return bOk;
}
-void Lock_Impl( SfxObjectShell const * pDoc, bool bLock )
+namespace
{
- SfxViewFrame *pFrame= SfxViewFrame::GetFirst( pDoc );
- while ( pFrame )
+class LockUIGuard
+{
+public:
+ LockUIGuard(SfxObjectShell const* pDoc)
+ : m_pDoc(pDoc)
{
- pFrame->GetDispatcher()->Lock( bLock );
- pFrame->Enable( !bLock );
- pFrame = SfxViewFrame::GetNext( *pFrame, pDoc );
+ Lock_Impl();
}
+ ~LockUIGuard() { Unlock(); }
-}
+ void Unlock()
+ {
+ if (m_bUnlock)
+ Lock_Impl();
+ }
+private:
+ void Lock_Impl()
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst(m_pDoc);
+ while (pFrame)
+ {
+ pFrame->GetDispatcher()->Lock(!m_bUnlock);
+ pFrame->Enable(m_bUnlock);
+ pFrame = SfxViewFrame::GetNext(*pFrame, m_pDoc);
+ }
+ m_bUnlock = !m_bUnlock;
+ }
+ SfxObjectShell const* m_pDoc;
+ bool m_bUnlock = false;
+};
+}
bool SfxObjectShell::SaveTo_Impl
(
@@ -1351,7 +1373,7 @@ bool SfxObjectShell::SaveTo_Impl
pImpl->bForbidReload = true;
// lock user interface while saving the document
- Lock_Impl( this, true );
+ LockUIGuard aLockUIGuard(this);
bool bOk = false;
// TODO/LATER: get rid of bOk
@@ -1360,8 +1382,7 @@ bool SfxObjectShell::SaveTo_Impl
uno::Reference< embed::XStorage > xMedStorage = rMedium.GetStorage();
if ( !xMedStorage.is() )
{
- // no saving without storage, unlock UI and return
- Lock_Impl( this, false );
+ // no saving without storage
pImpl->bForbidReload = bOldStat;
return false;
}
@@ -1663,7 +1684,7 @@ bool SfxObjectShell::SaveTo_Impl
}
// unlock user interface
- Lock_Impl( this, false );
+ aLockUIGuard.Unlock();
pImpl->bForbidReload = bOldStat;
if ( bOk )
More information about the Libreoffice-commits
mailing list