Changeset 25105 in webkit


Ignore:
Timestamp:
Aug 15, 2007 9:34:11 PM (17 years ago)
Author:
mjs
Message:

2007-08-15 Maciej Stachowiak <mjs@apple.com>

Reviewed by Geoff.

<rdar://problem/5389696> leak of 32-byte NSData object (and more?) in WebIconDatabase code path with each refresh of http://www.apple.com


  • platform/graphics/BitmapImage.h: Use RetainPtr for m_nsImage and m_tiffRep
  • platform/graphics/mac/ImageMac.mm: (WebCore::BitmapImage::initPlatformData): No need to do anything now (WebCore::BitmapImage::invalidatePlatformData): Simplify (WebCore::BitmapImage::getTIFFRepresentation): Use RetainPtr to avoid leaks (WebCore::BitmapImage::getNSImage): Use RetainPtr to avoid leaks
Location:
trunk/WebCore/platform/graphics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/platform/graphics/BitmapImage.h

    r23733 r25105  
    3333
    3434#if PLATFORM(MAC)
     35#include <wtf/RetainPtr.h>
    3536#ifdef __OBJC__
    3637@class NSImage;
     
    176177
    177178#if PLATFORM(MAC)
    178     mutable NSImage* m_nsImage; // A cached NSImage of frame 0. Only built lazily if someone actually queries for one.
    179     mutable CFDataRef m_tiffRep; // Cached TIFF rep for frame 0.  Only built lazily if someone queries for one.
     179    mutable RetainPtr<NSImage> m_nsImage; // A cached NSImage of frame 0. Only built lazily if someone actually queries for one.
     180    mutable RetainPtr<CFDataRef> m_tiffRep; // Cached TIFF rep for frame 0.  Only built lazily if someone queries for one.
    180181#endif
    181182
  • trunk/WebCore/platform/graphics/mac/ImageMac.mm

    r24789 r25105  
    3838void BitmapImage::initPlatformData()
    3939{
    40     m_nsImage = 0;
    41     m_tiffRep = 0;
    4240}
    4341
     
    4745        return;
    4846
    49     if (m_nsImage) {
    50         CFRelease(m_nsImage);
    51         m_nsImage = 0;
    52     }
    53 
    54     if (m_tiffRep) {
    55         CFRelease(m_tiffRep);
    56         m_tiffRep = 0;
    57     }
     47    m_nsImage = 0;
     48    m_tiffRep = 0;
    5849}
    5950
     
    7465{
    7566    if (m_tiffRep)
    76         return m_tiffRep;
     67        return m_tiffRep.get();
    7768   
    7869    unsigned numFrames = frameCount();
     
    9384    unsigned numValidFrames = images.size();
    9485   
    95     CFMutableDataRef data = CFDataCreateMutable(0, 0);
     86    RetainPtr<CFMutableDataRef> data(AdoptCF, CFDataCreateMutable(0, 0));
    9687    // FIXME:  Use type kCGImageTypeIdentifierTIFF constant once is becomes available in the API
    97     CGImageDestinationRef destination = CGImageDestinationCreateWithData(data, CFSTR("public.tiff"), numValidFrames, 0);
     88    CGImageDestinationRef destination = CGImageDestinationCreateWithData(data.get(), CFSTR("public.tiff"), numValidFrames, 0);
    9889   
    9990    if (!destination)
     
    10798
    10899    m_tiffRep = data;
    109     return m_tiffRep;
     100    return m_tiffRep.get();
    110101}
    111102
     
    113104{
    114105    if (m_nsImage)
    115         return m_nsImage;
     106        return m_nsImage.get();
    116107
    117108    CFDataRef data = getTIFFRepresentation();
     
    119110        return 0;
    120111   
    121     m_nsImage = HardRetainWithNSRelease([[NSImage alloc] initWithData:(NSData*)data]);
    122     return m_nsImage;
     112    m_nsImage.adoptNS([[NSImage alloc] initWithData:(NSData*)data]);
     113    return m_nsImage.get();
    123114}
    124115
Note: See TracChangeset for help on using the changeset viewer.