Bug 1330755 - Properly release the window device context. r=jimm
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 12 Jan 2017 17:25:12 -0500
changeset 374205 eca7348f32d8410559e342bff1a7698ceb2e9a30
parent 374204 7dd21e62c1f82a5635d70844598949eb2b0a29a5
child 374253 91f5293e9a89056565493ed5073c3842b0ee9fdc
child 374256 0b5439723dcb396025bcd4d45781b5709ff5d357
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1330755
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.