Changeset 178397 in webkit


Ignore:
Timestamp:
Jan 13, 2015 5:34:31 PM (9 years ago)
Author:
Joseph Pecoraro
Message:

NSButtonCell leak allocated under WebCore::paintToggleButton
https://bugs.webkit.org/show_bug.cgi?id=137014

Reviewed by Alexey Proskuryakov.

  • platform/mac/ThemeMac.mm:

(WebCore::createToggleButtonCell):
Immediately adopt the NSButtonCell allocation.

(WebCore::sharedRadioCell):
(WebCore::sharedCheckboxCell):
Move from the RetainPtr into the static variable.

(WebCore::paintToggleButton):
Use RetainPtr logic to better manage lifetimes.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r178396 r178397  
     12015-01-13  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        NSButtonCell leak allocated under WebCore::paintToggleButton
     4        https://bugs.webkit.org/show_bug.cgi?id=137014
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * platform/mac/ThemeMac.mm:
     9        (WebCore::createToggleButtonCell):
     10        Immediately adopt the NSButtonCell allocation.
     11
     12        (WebCore::sharedRadioCell):
     13        (WebCore::sharedCheckboxCell):
     14        Move from the RetainPtr into the static variable.
     15
     16        (WebCore::paintToggleButton):
     17        Use RetainPtr logic to better manage lifetimes.
     18
    1192015-01-13  Zalan Bujtas  <zalan@apple.com>
    220
  • trunk/Source/WebCore/platform/mac/ThemeMac.mm

    r176751 r178397  
    3333#import "WebCoreSystemInterface.h"
    3434#import <Carbon/Carbon.h>
    35 #include <wtf/StdLibExtras.h>
     35#import <wtf/StdLibExtras.h>
    3636
    3737#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     
    343343}
    344344   
    345 static NSButtonCell *createToggleButtonCell(ControlPart buttonType)
    346 {
    347     NSButtonCell *toggleButtonCell = [[NSButtonCell alloc] init];
     345static RetainPtr<NSButtonCell> createToggleButtonCell(ControlPart buttonType)
     346{
     347    RetainPtr<NSButtonCell> toggleButtonCell = adoptNS([[NSButtonCell alloc] init]);
    348348   
    349349    if (buttonType == CheckboxPart) {
     
    362362static NSButtonCell *sharedRadioCell(const ControlStates* states, const IntSize& zoomedSize, float zoomFactor)
    363363{
    364     static NSButtonCell *radioCell;
    365     if (!radioCell)
    366         radioCell = createToggleButtonCell(RadioPart);
     364    static NSButtonCell *radioCell = createToggleButtonCell(RadioPart).leakRef();
    367365
    368366    configureToggleButton(radioCell, RadioPart, states, zoomedSize, zoomFactor, false);
     
    372370static NSButtonCell *sharedCheckboxCell(const ControlStates* states, const IntSize& zoomedSize, float zoomFactor)
    373371{
    374     static NSButtonCell *checkboxCell;
    375     if (!checkboxCell)
    376         checkboxCell = createToggleButtonCell(CheckboxPart);
     372    static NSButtonCell *checkboxCell = createToggleButtonCell(CheckboxPart).leakRef();
    377373
    378374    configureToggleButton(checkboxCell, CheckboxPart, states, zoomedSize, zoomFactor, false);
     
    390386    BEGIN_BLOCK_OBJC_EXCEPTIONS
    391387
    392     NSButtonCell *toggleButtonCell = static_cast<NSButtonCell*>(controlStates->platformControl());
     388    RetainPtr<NSButtonCell> toggleButtonCell = static_cast<NSButtonCell *>(controlStates->platformControl());
    393389    IntSize zoomedRectSize = IntSize(zoomedRect.size());
    394390
     
    396392        if (!toggleButtonCell)
    397393            toggleButtonCell = createToggleButtonCell(buttonType);
    398         configureToggleButton(toggleButtonCell, buttonType, controlStates, zoomedRectSize, zoomFactor, true);
     394        configureToggleButton(toggleButtonCell.get(), buttonType, controlStates, zoomedRectSize, zoomFactor, true);
    399395    } else {
    400396        if (!toggleButtonCell) {
     
    406402            }
    407403        }
    408         configureToggleButton(toggleButtonCell, buttonType, controlStates, zoomedRectSize, zoomFactor, false);
     404        configureToggleButton(toggleButtonCell.get(), buttonType, controlStates, zoomedRectSize, zoomFactor, false);
    409405    }
    410406    controlStates->setDirty(false);
     
    450446
    451447    if (!isAnimating && (controlStates->states() & ControlStates::FocusState))
    452         needsRepaint = drawCellFocusRing(toggleButtonCell, inflatedRect, view);
     448        needsRepaint = drawCellFocusRing(toggleButtonCell.get(), inflatedRect, view);
    453449    [toggleButtonCell setControlView:nil];
    454450
     
    458454    controlStates->setNeedsRepaint(needsRepaint);
    459455    if (needsRepaint)
    460         controlStates->setPlatformControl(toggleButtonCell);
     456        controlStates->setPlatformControl(toggleButtonCell.get());
    461457
    462458    END_BLOCK_OBJC_EXCEPTIONS
Note: See TracChangeset for help on using the changeset viewer.