Bug 730277 - Hold reference until data used in CreateIcon r=joe
authorEthan Hugg <ethanhugg@gmail.com>
Fri, 22 Mar 2013 15:57:50 -0700
changeset 125993 f8613cef1d5467f3c6b97ff28ad5dbc3c5e90570
parent 125992 6c50015e207352fce95beb33e2afb6f4aa1792c9
child 125994 7437279a223deaa369110a4f177ab31ec5b161ca
push id25220
push userehugg@cisco.com
push dateSat, 23 Mar 2013 02:54:42 +0000
treeherdermozilla-inbound@f8613cef1d54 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs730277
milestone22.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 730277 - Hold reference until data used in CreateIcon r=joe
widget/windows/nsWindowGfx.cpp
--- a/widget/windows/nsWindowGfx.cpp
+++ b/widget/windows/nsWindowGfx.cpp
@@ -618,27 +618,28 @@ nsresult nsWindowGfx::CreateIcon(imgICon
   NS_ENSURE_TRUE(frame, NS_ERROR_NOT_AVAILABLE);
 
   int32_t width = frame->Width();
   int32_t height = frame->Height();
   if (!width || !height)
     return NS_ERROR_FAILURE;
 
   uint8_t *data;
+  nsRefPtr<gfxImageSurface> dest;
+
   if ((aScaledSize.width == 0 && aScaledSize.height == 0) ||
       (aScaledSize.width == width && aScaledSize.height == height)) {
     // We're not scaling the image. The data is simply what's in the frame.
     data = frame->Data();
   }
   else {
     NS_ENSURE_ARG(aScaledSize.width > 0);
     NS_ENSURE_ARG(aScaledSize.height > 0);
     // Draw a scaled version of the image to a temporary surface
-    nsRefPtr<gfxImageSurface> dest = new gfxImageSurface(aScaledSize,
-                                                         gfxASurface::ImageFormatARGB32);
+    dest = new gfxImageSurface(aScaledSize, gfxASurface::ImageFormatARGB32);
     if (!dest)
       return NS_ERROR_OUT_OF_MEMORY;
 
     gfxContext ctx(dest);
 
     // Set scaling
     gfxFloat sw = (double) aScaledSize.width / width;
     gfxFloat sh = (double) aScaledSize.height / height;