Changeset 178397 in webkit
- Timestamp:
- Jan 13, 2015 5:34:31 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r178396 r178397 1 2015-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 1 19 2015-01-13 Zalan Bujtas <zalan@apple.com> 2 20 -
trunk/Source/WebCore/platform/mac/ThemeMac.mm
r176751 r178397 33 33 #import "WebCoreSystemInterface.h" 34 34 #import <Carbon/Carbon.h> 35 #i nclude<wtf/StdLibExtras.h>35 #import <wtf/StdLibExtras.h> 36 36 37 37 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 … … 343 343 } 344 344 345 static NSButtonCell *createToggleButtonCell(ControlPart buttonType)346 { 347 NSButtonCell *toggleButtonCell = [[NSButtonCell alloc] init];345 static RetainPtr<NSButtonCell> createToggleButtonCell(ControlPart buttonType) 346 { 347 RetainPtr<NSButtonCell> toggleButtonCell = adoptNS([[NSButtonCell alloc] init]); 348 348 349 349 if (buttonType == CheckboxPart) { … … 362 362 static NSButtonCell *sharedRadioCell(const ControlStates* states, const IntSize& zoomedSize, float zoomFactor) 363 363 { 364 static NSButtonCell *radioCell; 365 if (!radioCell) 366 radioCell = createToggleButtonCell(RadioPart); 364 static NSButtonCell *radioCell = createToggleButtonCell(RadioPart).leakRef(); 367 365 368 366 configureToggleButton(radioCell, RadioPart, states, zoomedSize, zoomFactor, false); … … 372 370 static NSButtonCell *sharedCheckboxCell(const ControlStates* states, const IntSize& zoomedSize, float zoomFactor) 373 371 { 374 static NSButtonCell *checkboxCell; 375 if (!checkboxCell) 376 checkboxCell = createToggleButtonCell(CheckboxPart); 372 static NSButtonCell *checkboxCell = createToggleButtonCell(CheckboxPart).leakRef(); 377 373 378 374 configureToggleButton(checkboxCell, CheckboxPart, states, zoomedSize, zoomFactor, false); … … 390 386 BEGIN_BLOCK_OBJC_EXCEPTIONS 391 387 392 NSButtonCell *toggleButtonCell = static_cast<NSButtonCell*>(controlStates->platformControl());388 RetainPtr<NSButtonCell> toggleButtonCell = static_cast<NSButtonCell *>(controlStates->platformControl()); 393 389 IntSize zoomedRectSize = IntSize(zoomedRect.size()); 394 390 … … 396 392 if (!toggleButtonCell) 397 393 toggleButtonCell = createToggleButtonCell(buttonType); 398 configureToggleButton(toggleButtonCell , buttonType, controlStates, zoomedRectSize, zoomFactor, true);394 configureToggleButton(toggleButtonCell.get(), buttonType, controlStates, zoomedRectSize, zoomFactor, true); 399 395 } else { 400 396 if (!toggleButtonCell) { … … 406 402 } 407 403 } 408 configureToggleButton(toggleButtonCell , buttonType, controlStates, zoomedRectSize, zoomFactor, false);404 configureToggleButton(toggleButtonCell.get(), buttonType, controlStates, zoomedRectSize, zoomFactor, false); 409 405 } 410 406 controlStates->setDirty(false); … … 450 446 451 447 if (!isAnimating && (controlStates->states() & ControlStates::FocusState)) 452 needsRepaint = drawCellFocusRing(toggleButtonCell , inflatedRect, view);448 needsRepaint = drawCellFocusRing(toggleButtonCell.get(), inflatedRect, view); 453 449 [toggleButtonCell setControlView:nil]; 454 450 … … 458 454 controlStates->setNeedsRepaint(needsRepaint); 459 455 if (needsRepaint) 460 controlStates->setPlatformControl(toggleButtonCell );456 controlStates->setPlatformControl(toggleButtonCell.get()); 461 457 462 458 END_BLOCK_OBJC_EXCEPTIONS
Note: See TracChangeset
for help on using the changeset viewer.