[Libreoffice-commits] core.git: vcl/win
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Jan 8 10:12:37 UTC 2019
vcl/win/gdi/gdiimpl.cxx | 10 ++++------
vcl/win/gdi/scoped_gdi.hxx | 7 +++++++
2 files changed, 11 insertions(+), 6 deletions(-)
New commits:
commit bcbcfa7927c575ddb1379b3cd8ef1b2df709ba66
Author: Dmitriy Shilin <dshil at fastmail.com>
AuthorDate: Sun Jan 6 23:53:45 2019 -0800
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Jan 8 11:12:14 2019 +0100
tdf#107792 vcl/win/gdi: introduce ScopedHRGN
Change-Id: I3d103dcb6ebb81d50bb8a10371dba7feb92c421d
Reviewed-on: https://gerrit.libreoffice.org/65924
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index 2eb537931d50..1bb39b84cd2e 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -296,9 +296,8 @@ void MakeInvisibleArea(const RECT& rSrcRect,
rhInvalidateRgn = CreateRectRgnIndirect(&rSrcRect);
}
- HRGN hTempRgn = CreateRectRgn(nLeft, nTop, nRight, nBottom);
- CombineRgn(rhInvalidateRgn, rhInvalidateRgn, hTempRgn, RGN_DIFF);
- DeleteRegion(hTempRgn);
+ ScopedHRGN hTempRgn(CreateRectRgn(nLeft, nTop, nRight, nBottom));
+ CombineRgn(rhInvalidateRgn, rhInvalidateRgn, hTempRgn.get(), RGN_DIFF);
}
void ImplCalcOutSideRgn( const RECT& rSrcRect,
@@ -1259,9 +1258,8 @@ bool WinSalGraphicsImpl::setClipRegion( const vcl::Region& i_rClip )
for( sal_uLong n = 1; n < pHeader.nCount; n++, pRect++ )
{
- HRGN hRgn = CreateRectRgn( pRect->left, pRect->top, pRect->right, pRect->bottom );
- CombineRgn( mrParent.mhRegion, mrParent.mhRegion, hRgn, RGN_OR );
- DeleteRegion( hRgn );
+ ScopedHRGN hRgn(CreateRectRgn(pRect->left, pRect->top, pRect->right, pRect->bottom));
+ CombineRgn( mrParent.mhRegion, mrParent.mhRegion, hRgn.get(), RGN_OR );
}
}
}
diff --git a/vcl/win/gdi/scoped_gdi.hxx b/vcl/win/gdi/scoped_gdi.hxx
index 64dbd180b969..90af7340f06a 100644
--- a/vcl/win/gdi/scoped_gdi.hxx
+++ b/vcl/win/gdi/scoped_gdi.hxx
@@ -21,7 +21,14 @@ struct HBRUSHDeleter
void operator()(HBRUSH hBrush) { DeleteBrush(hBrush); }
};
+struct HRGNDeleter
+{
+ using pointer = HRGN;
+ void operator()(HRGN hRgn) { DeleteRegion(hRgn); }
+};
+
using ScopedHBRUSH = std::unique_ptr<HBRUSH, HBRUSHDeleter>;
+using ScopedHRGN = std::unique_ptr<HRGN, HRGNDeleter>;
#endif // INCLUDED_VCL_WIN_GDI_SCOPED_GDI_HXX
More information about the Libreoffice-commits
mailing list