Bug 1330755 - Properly release the window device context. r?jimm draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 12 Jan 2017 17:25:12 -0500
changeset 460064 e08a396483cf1e0c08abbfb790d4878e2e699304
parent 459754 6e5f04db4c4a95ad509224b238fd3ad464281e6b
child 542020 eceba6a93883f3479e577273d6e715157ade5e1b
push id41359
push userkgupta@mozilla.com
push dateThu, 12 Jan 2017 22:25:56 +0000
reviewersjimm
bugs1330755
milestone53.0a1
Bug 1330755 - Properly release the window device context. r?jimm MozReview-Commit-ID: 7Y3p4g3yI3s
widget/windows/nsWindow.cpp
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -1418,17 +1418,20 @@ nsWindow::CreateScrollSnapshot()
   }
 
   // Check that the window is in a position to snapshot. We don't check for
   // clipped width as that doesn't currently matter for APZ scrolling.
   if (clip.top || clip.bottom != mBounds.height) {
     return GetFallbackScrollSnapshot(clip);
   }
 
-  nsAutoHDC windowDC(::GetDC(mWnd));
+  HDC windowDC = ::GetDC(mWnd);
+  auto releaseDC = MakeScopeExit([&] {
+    ::ReleaseDC(mWnd, windowDC);
+  });
   if (!windowDC) {
     return GetFallbackScrollSnapshot(clip);
   }
 
   gfx::IntSize snapshotSize(mBounds.width, mBounds.height);
   ScrollSnapshot* snapshot;
   if (clip.left || clip.right != mBounds.width) {
     // Can't do a full snapshot, so use the partial snapshot.