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-29 16:34:07 +0000 |
commit | 98d2d985082114ec259c11788af7b8574f2c9b3d (patch) | |
tree | dac5fc23dd935013b631049c5c8a65836fc7797b /sw | |
parent | 30396941dbaa34d3573466a87e435621cfdadab3 (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>
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 4ace932fbb69..7998259308de 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 ) |