Bug 1401069 - Part 1. Release EMF handle before function exist. draft
authorcku <cku@mozilla.com>
Mon, 18 Sep 2017 23:10:01 +0800
changeset 667428 7bbf173f04a9b9a3ec5ea68e46378ae206f1b8ad
parent 667303 a0eb21bf55e1c1ae0ba311e6f2273da05c712799
child 667429 df86dfc20144aaa57a2b0433fd307e21b13034bb
push id80696
push usercku@mozilla.com
push dateWed, 20 Sep 2017 02:55:24 +0000
bugs1401069
milestone57.0a1
Bug 1401069 - Part 1. Release EMF handle before function exist. This is to make the behavior of WindowsEMF::Playback be consentient with WindowsEMF::SaveToFile. MozReview-Commit-ID: GANdQ7MtEPq
widget/windows/WindowsEMF.cpp
--- a/widget/windows/WindowsEMF.cpp
+++ b/widget/windows/WindowsEMF.cpp
@@ -64,23 +64,27 @@ WindowsEMF::ReleaseEMFHandle()
 bool
 WindowsEMF::Playback(HDC aDeviceContext, const RECT* aRect)
 {
   MOZ_ASSERT(aRect);
   if (!FinishDocument()) {
     return false;
   }
 
-  return ::PlayEnhMetaFile(aDeviceContext, mEmf, aRect) != 0;
+  bool result = ::PlayEnhMetaFile(aDeviceContext, mEmf, aRect) != 0;
+  ReleaseEMFHandle();
+
+  return result;
 }
 
 bool
 WindowsEMF::SaveToFile()
 {
   if (!FinishDocument()) {
     return false;
   }
+
   ReleaseEMFHandle();
   return true;
 }
 
 } // namespace widget
 } // namespace mozilla
\ No newline at end of file