Fix for <rdar://problem/8953365> CrashTracer: 14
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Feb 2011 22:11:34 +0000 (22:11 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Feb 2011 22:11:34 +0000 (22:11 +0000)
crashes in WebProcess at com.apple.WebCore:
-[ScrollKnobAnimation setCurrentProgress:] + 258

Reviewed by Darin Adler.

This crash seems to happen when the animation is running
and a window is closed. If the ScrollAnimator is destroyed,
delegate calls for the animation can still run, so we have
to make sure we inform the delegates when the ScrollAnimator
is gone, and then we have to null-check it before we do
anything with it.

Remove scrollbarPainterDelegate() since it's not used anymore.
* platform/mac/ScrollAnimatorMac.h:
* platform/mac/ScrollAnimatorMac.mm:

Add null-checks for _animator
(-[ScrollbarPartAnimation setCurrentProgress:]):
(-[ScrollbarPartAnimation scrollAnimatorDestroyed]):
(-[ScrollbarPainterDelegate scrollerImp:animateKnobAlphaTo:duration:]):
(-[ScrollbarPainterDelegate scrollerImp:animateTrackAlphaTo:duration:]):
(-[ScrollbarPainterDelegate scrollerImp:overlayScrollerStateChangedTo:]):

New function to inform the delegates that the ScrollAnimator
is being destroyed.
(-[ScrollbarPainterDelegate scrollAnimatorDestroyed]):
(WebCore::ScrollAnimatorMac::~ScrollAnimatorMac):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@77970 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mac/ScrollAnimatorMac.h
Source/WebCore/platform/mac/ScrollAnimatorMac.mm

index 4637817..feba030 100644 (file)
@@ -1,3 +1,34 @@
+2011-02-08  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Fix for <rdar://problem/8953365> CrashTracer: 14 
+        crashes in WebProcess at com.apple.WebCore: 
+        -[ScrollKnobAnimation setCurrentProgress:] + 258
+
+        This crash seems to happen when the animation is running
+        and a window is closed. If the ScrollAnimator is destroyed,
+        delegate calls for the animation can still run, so we have 
+        to make sure we inform the delegates when the ScrollAnimator 
+        is gone, and then we have to null-check it before we do 
+        anything with it.
+
+        Remove scrollbarPainterDelegate() since it's not used anymore.
+        * platform/mac/ScrollAnimatorMac.h:
+        * platform/mac/ScrollAnimatorMac.mm:
+        
+        Add null-checks for _animator
+        (-[ScrollbarPartAnimation setCurrentProgress:]):
+        (-[ScrollbarPartAnimation scrollAnimatorDestroyed]):
+        (-[ScrollbarPainterDelegate scrollerImp:animateKnobAlphaTo:duration:]):
+        (-[ScrollbarPainterDelegate scrollerImp:animateTrackAlphaTo:duration:]):
+        (-[ScrollbarPainterDelegate scrollerImp:overlayScrollerStateChangedTo:]):
+        
+        New function to inform the delegates that the ScrollAnimator
+        is being destroyed.
+        (-[ScrollbarPainterDelegate scrollAnimatorDestroyed]):
+        (WebCore::ScrollAnimatorMac::~ScrollAnimatorMac):
+
 2011-02-08  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Eric Seidel.
index b839cdd..79201e7 100644 (file)
@@ -70,8 +70,6 @@ public:
     void immediateScrollToPoint(const FloatPoint& newPosition);
     void immediateScrollByDeltaX(float deltaX);
     void immediateScrollByDeltaY(float deltaY);
-
-    id scrollbarPainterDelegate();
     
 private:
     RetainPtr<id> m_scrollAnimationHelper;
index a3a86a9..a781d9d 100644 (file)
@@ -278,6 +278,9 @@ static NSSize abs(NSSize size)
 {
     [super setCurrentProgress:progress];
 
+    if (!_animator)
+        return;
+
     CGFloat currentAlpha;
     if (_initialAlpha > _newAlpha)
         currentAlpha = 1 - progress;
@@ -296,6 +299,11 @@ static NSSize abs(NSSize size)
         _animator->scrollableArea()->invalidateScrollbarRect(horizontalScrollbar, WebCore::IntRect(0, 0, horizontalScrollbar->width(), horizontalScrollbar->height()));
 }
 
+- (void)scrollAnimatorDestroyed
+{
+    _animator = 0;
+}
+
 @end
 
 @interface ScrollbarPainterDelegate : NSObject<NSAnimationDelegate>
@@ -319,6 +327,8 @@ static NSSize abs(NSSize size)
 - (void)scrollerImp:(id)scrollerImp animateTrackAlphaTo:(CGFloat)newTrackAlpha duration:(NSTimeInterval)duration;
 - (void)scrollerImp:(id)scrollerImp overlayScrollerStateChangedTo:(NSUInteger)newOverlayScrollerState;
 
+- (void)scrollAnimatorDestroyed;
+
 @end
 
 @implementation ScrollbarPainterDelegate
@@ -367,6 +377,9 @@ static NSSize abs(NSSize size)
 
 - (void)scrollerImp:(id)scrollerImp animateKnobAlphaTo:(CGFloat)newKnobAlpha duration:(NSTimeInterval)duration
 {
+    if (!_animator)
+        return;
+
     WKScrollbarPainterRef scrollerPainter = (WKScrollbarPainterRef)scrollerImp;
     if (newKnobAlpha == wkScrollbarPainterKnobAlpha(scrollerPainter))
         return;
@@ -379,6 +392,9 @@ static NSSize abs(NSSize size)
 
 - (void)scrollerImp:(id)scrollerImp animateTrackAlphaTo:(CGFloat)newTrackAlpha duration:(NSTimeInterval)duration
 {
+    if (!_animator)
+        return;
+
     WKScrollbarPainterRef scrollerPainter = (WKScrollbarPainterRef)scrollerImp;
     if (newTrackAlpha == wkScrollbarPainterTrackAlpha(scrollerPainter))
         return;
@@ -391,6 +407,9 @@ static NSSize abs(NSSize size)
 
 - (void)scrollerImp:(id)scrollerImp overlayScrollerStateChangedTo:(NSUInteger)newOverlayScrollerState
 {
+    if (!_animator)
+        return;
+
     WKScrollbarPainterRef scrollbarPainter = (WKScrollbarPainterRef)scrollerImp;
     wkScrollbarPainterSetOverlayState(scrollbarPainter, newOverlayScrollerState);
 
@@ -404,6 +423,15 @@ static NSSize abs(NSSize size)
     }
 }
 
+- (void)scrollAnimatorDestroyed
+{
+    _animator = 0;
+    [_verticalKnobAnimation.get() scrollAnimatorDestroyed];
+    [_horizontalKnobAnimation.get() scrollAnimatorDestroyed];
+    [_verticalTrackAnimation.get() scrollAnimatorDestroyed];
+    [_horizontalTrackAnimation.get() scrollAnimatorDestroyed];
+}
+
 @end
 #endif // #if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
 
@@ -439,15 +467,7 @@ ScrollAnimatorMac::~ScrollAnimatorMac()
 {
 #if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
     [(id)m_scrollbarPainterController.get() setDelegate:nil];
-#endif
-}
-
-id ScrollAnimatorMac::scrollbarPainterDelegate()
-{
-#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
-    return m_scrollbarPainterDelegate.get();
-#else
-    return nil;
+    [(id)m_scrollbarPainterDelegate.get() scrollAnimatorDestroyed];
 #endif
 }