Bug 1330755 - Properly release the window device context. r=jimm, a=jcristau
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 12 Jan 2017 17:25:12 -0500
changeset 353721 69f54dcd72c6f5b5ae1279a381727f05004d3cc1
parent 353720 614d5cdce0beeea2fab025e3c1e6977c85f25574
child 353722 3c1334c6b10e98e9aab01ec6bc083f5dc6d80857
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm, jcristau
bugs1330755
milestone52.0a2
Bug 1330755 - Properly release the window device context. r=jimm, a=jcristau MozReview-Commit-ID: 7Y3p4g3yI3s
widget/windows/nsWindow.cpp
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -1411,17 +1411,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.