diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2021-10-12 10:33:36 +0200 |
---|---|---|
committer | Mark Hung <marklh9@gmail.com> | 2021-10-17 15:33:45 +0200 |
commit | a2adb7fa926c2b9ed053c65e130a9da336cc98b0 (patch) | |
tree | dd95b1817f5c2a12b70fefc0db6b874a55576642 /vcl/win | |
parent | 23cded985ba0131f85ee445492c04871fbfb6351 (diff) |
WIN release SalPrinter's SalGraphics borrowed HDC
Regression from commit d27187b158d7e3f92180b1f2ab79b048dc5318a5
("vcl:use unique_ptr<SalWinGraphics> in WinSalPrinter").
Would need something like Rust's Borrowing semantics to prevent.
Ideas on IRC to make this bug more unlikely were some extra HDC +
SalGraphics struct to pass around or something like unique_ptr
reference passing and moving the value into a local copy.
For now just add some additional comments.
Change-Id: I472ee9acb4a4c02177c27ecd1c1277dfc812cadf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123440
Tested-by: Jenkins
Reviewed-by: Mark Hung <marklh9@gmail.com>
Diffstat (limited to 'vcl/win')
-rw-r--r-- | vcl/win/gdi/salprn.cxx | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx index 86e1e616a57f..332c7a8dfaae 100644 --- a/vcl/win/gdi/salprn.cxx +++ b/vcl/win/gdi/salprn.cxx @@ -1373,6 +1373,9 @@ WinSalPrinter::~WinSalPrinter() HDC hDC = mhDC; if ( hDC ) { + // explicitly reset(), so the mxGraphics's borrowed HDC defaults are + // restored and WinSalGraphics's destructor won't work on a deleted HDC. + mxGraphics.reset(); DeleteDC( hDC ); } |