diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-06-29 17:05:50 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-06-30 09:53:00 +0200 |
commit | b265e4e9d63d4603ec6985fedf6941bdbcba4d74 (patch) | |
tree | 9a3a3839b088b1a1ff12ec4af0ac3c3ab45b8c53 /sw | |
parent | 4a25cccd6419844c38a7a6eebb5cd484a0b48097 (diff) |
SwViewShell::Paint: restore old render context at the end
The idea is that mpOut is only used for non-drawing purposes outside
Paint(), e.g. to do logic <-> pixel conversion.
Change-Id: Ia83cd32dd0a5152dcfc1644e92af08b4ddf4653c
Reviewed-on: https://gerrit.libreoffice.org/16584
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit 98d2d985082114ec259c11788af7b8574f2c9b3d)
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/view/viewsh.cxx | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 89940c6509d6..fa443ab4c2a4 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -1664,9 +1664,32 @@ bool SwViewShell::CheckInvalidForPaint( const SwRect &rRect ) return bRet; } +namespace +{ +/// Similar to comphelper::FlagRestorationGuard, but for vcl::RenderContext. +class RenderContextGuard +{ + VclPtr<vcl::RenderContext>& m_pRef; + vcl::RenderContext* m_pOriginalValue; + +public: + RenderContextGuard(VclPtr<vcl::RenderContext>& pRef, vcl::RenderContext* pValue) + : m_pRef(pRef), + m_pOriginalValue(m_pRef) + { + m_pRef = pValue; + } + + ~RenderContextGuard() + { + m_pRef = m_pOriginalValue; + } +}; +} + void SwViewShell::Paint(vcl::RenderContext& rRenderContext, const Rectangle &rRect) { - mpOut = &rRenderContext; + RenderContextGuard aGuard(mpOut, &rRenderContext); if ( mnLockPaint ) { if ( Imp()->bSmoothUpdate ) |