[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

cblu cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:29:23 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 0a8d5d70d9c46c33fd78a3392a7c83d5868a1b3f
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Mar 13 00:14:12 2003 +0000

    	3196673 - REGRESSION: Assertion failure when download fails to create file
    	- Retain the download delegate because it will live longer than the WebController which it is an instance of.
    
            Reviewed by rjw.
    
            * Downloads.subproj/WebDownload.m:
            (-[WebDownload _initWithLoadingResource:request:response:delegate:proxy:]): call _downloadStarted
            (-[WebDownload loadWithDelegate:]): call _downloadStarted
            (-[WebDownload _downloadStarted]): renamed from _loadStarted
            (-[WebDownload _downloadEnded]): release delegate
            (-[WebDownload resource:willSendRequest:]): reordered so if we are released in this method, we never call self
            (-[WebDownload resourceDidFinishLoading:]): don't call _loadEnded because _downloadEnded gets called in _didCloseFile and _cancelWithError
            (-[WebDownload resource:didFailLoadingWithError:]):  don't call _loadEnded because _downloadEnded gets called in _didCloseFile and _cancelWithError
            (-[WebDownload _didCloseFile:]): call _downloadEnded
            (-[WebDownload _cancelWithError:]): call _downloadEnded
            * WebView.subproj/WebController.h: mention that the download delegate gets retained.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3812 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 42fb97a..d7aefa5 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,22 @@
+2003-03-12  Chris Blumenberg  <cblu at apple.com>
+
+	3196673 - REGRESSION: Assertion failure when download fails to create file
+	- Retain the download delegate because it will live longer than the WebController which it is an instance of.
+
+        Reviewed by rjw.
+
+        * Downloads.subproj/WebDownload.m:
+        (-[WebDownload _initWithLoadingResource:request:response:delegate:proxy:]): call _downloadStarted
+        (-[WebDownload loadWithDelegate:]): call _downloadStarted
+        (-[WebDownload _downloadStarted]): renamed from _loadStarted
+        (-[WebDownload _downloadEnded]): release delegate
+        (-[WebDownload resource:willSendRequest:]): reordered so if we are released in this method, we never call self
+        (-[WebDownload resourceDidFinishLoading:]): don't call _loadEnded because _downloadEnded gets called in _didCloseFile and _cancelWithError
+        (-[WebDownload resource:didFailLoadingWithError:]):  don't call _loadEnded because _downloadEnded gets called in _didCloseFile and _cancelWithError
+        (-[WebDownload _didCloseFile:]): call _downloadEnded
+        (-[WebDownload _cancelWithError:]): call _downloadEnded
+        * WebView.subproj/WebController.h: mention that the download delegate gets retained.
+
 2003-03-12  Darin Adler  <darin at apple.com>
 
         Reviewed by John.
diff --git a/WebKit/Downloads.subproj/WebDownload.m b/WebKit/Downloads.subproj/WebDownload.m
index b6eeb0a..bba67c5 100644
--- a/WebKit/Downloads.subproj/WebDownload.m
+++ b/WebKit/Downloads.subproj/WebDownload.m
@@ -50,7 +50,7 @@ typedef struct WebFSRefParam
     SInt16 resourceForkRefNum;
 
     BOOL deleteFile;
-    BOOL isLoading;
+    BOOL isDownloading;
     BOOL areWritesCancelled;
     BOOL encounteredCloseError;
 
@@ -75,8 +75,8 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
 
 @interface WebDownload (ForwardDeclarations)
 #pragma mark LOADING
-- (void)_loadStarted;
-- (void)_loadEnded;
+- (void)_downloadStarted;
+- (void)_downloadEnded;
 - (void)_setRequest:(WebRequest *)request;
 - (void)_setResponse:(WebResponse *)response;
 #pragma mark CREATING
@@ -106,6 +106,7 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
 - (void)_cancelWithError:(WebError *)error;
 - (void)_cancelWithErrorCode:(int)code;
 #pragma mark MISC
+- (void)_setDelegate:(id)delegate;
 - (void)_setPath:(NSString *)path;
 - (NSString *)_currentPath;
 - (WebError *)_errorWithCode:(int)code;
@@ -140,7 +141,7 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
 {
     ASSERT(!resource);
     ASSERT(!delegate);
-    ASSERT(!isLoading);
+    ASSERT(!isDownloading);
 
     free(fileRefPtr);
     
@@ -186,15 +187,16 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
                      proxy:(WebResourceDelegateProxy *)proxy
 {
     [super init];
-    
+     
     _private = [[WebDownloadPrivate alloc] init];
+    [self _downloadStarted];
+    
     _private->request =  [request retain];
     _private->resource = [resource retain];
     _private->response = [response retain];
-    _private->delegate = delegate;
     _private->proxy = 	 [proxy retain];
+    [self _setDelegate:delegate];
     [_private->proxy setDelegate:(id <WebResourceDelegate>)self];
-    [self _loadStarted];
 
     // Replay the delegate methods that would be called in the standalone download case.
     if ([_private->delegate respondsToSelector:@selector(download:didStartFromRequest:)]) {
@@ -216,7 +218,7 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
                     return nil;
                 }
                 [_private->resource loadWithDelegate:(id <WebResourceDelegate>)self];
-                [self _loadStarted];
+                [self _downloadStarted];
             }
             return self;
         }
@@ -250,11 +252,11 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
 
 - (void)loadWithDelegate:(id)delegate
 {
-    if (!_private->isLoading) {
-        _private->delegate = delegate;
+    if (!_private->isDownloading) {
+        [self _downloadStarted];
+        
+        [self _setDelegate:delegate];
         [_private->resource loadWithDelegate:(id <WebResourceDelegate>)self];
-
-        [self _loadStarted];
         
         if ([_private->delegate respondsToSelector:@selector(download:didStartFromRequest:)]) {
             [_private->delegate download:self didStartFromRequest:_private->request];
@@ -280,24 +282,26 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
 
 #pragma mark LOADING
 
-- (void)_loadStarted
+- (void)_downloadStarted
 {
-    if (!_private->isLoading) {
-        _private->isLoading = YES;
+    if (!_private->isDownloading) {
+        _private->isDownloading = YES;
         
         // Retain self while loading so we aren't released during the load.
         [self retain];
     }
 }
 
-- (void)_loadEnded
+- (void)_downloadEnded
 {
-    if (_private->isLoading) {
-        _private->isLoading = NO;
+    if (_private->isDownloading) {
+        _private->isDownloading = NO;
 
         [_private->resource release];
         _private->resource = nil;
 
+        [self _setDelegate:nil];
+
         // Balance the retain from when the load started.
         [self release];
     }
@@ -328,13 +332,13 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
     } else {
         request = theRequest;
     }
+
+    [self _setRequest:request];
     
     if (!request) {
-        [self _loadEnded];
+        [self _downloadEnded];
     }
 
-    [self _setRequest:request];
-
     return request;
 }
 
@@ -360,9 +364,7 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
 }
 
 -(void)resourceDidFinishLoading:(WebResource *)resource
-{
-    [self _loadEnded];
-    
+{    
     WebError *error = [self _decodeData:_private->bufferedData];
     [_private->bufferedData release];
     _private->bufferedData = nil;
@@ -381,9 +383,7 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
 }
 
 -(void)resource:(WebResource *)resource didFailLoadingWithError:(WebError *)error
-{
-    [self _loadEnded];
-    
+{    
     [self _cancelWithError:error];
 }
 
@@ -729,7 +729,7 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
         if ([_private->delegate respondsToSelector:@selector(downloadDidFinishDownloading:)]) {
             [_private->delegate downloadDidFinishDownloading:self];
         }
-        _private->delegate = nil;
+        [self _downloadEnded];
     }
 }
 
@@ -815,17 +815,14 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
 {
     [_private->resource cancel];
     
-    [self _loadEnded];
-
     if (error) {
         if ([_private->delegate respondsToSelector:@selector(download:didFailDownloadingWithError:)]) {
             [_private->delegate download:self didFailDownloadingWithError:error];
         }
     }
 
-    _private->delegate = nil;
-
     [self _closeAndDeleteFileAsync];
+    [self _downloadEnded];
 }
 
 - (void)_cancelWithErrorCode:(int)code
@@ -835,6 +832,13 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
 
 #pragma mark MISCELLANEOUS
 
+- (void)_setDelegate:(id)delegate;
+{
+    [delegate retain];
+    [_private->delegate release];
+    _private->delegate = delegate;
+}
+
 - (void)_setPath:(NSString *)path
 {
     ASSERT(path);
diff --git a/WebKit/WebView.subproj/WebController.h b/WebKit/WebView.subproj/WebController.h
index 054d947..7f78f60 100644
--- a/WebKit/WebView.subproj/WebController.h
+++ b/WebKit/WebView.subproj/WebController.h
@@ -155,6 +155,7 @@ extern NSString *WebElementLinkLabelKey;	// NSString of the text within the anch
 /*!
     @method setDownloadDelegate:
     @abstract Set the controller's WebDownloadDelegate.
+    @discussion The download delegate is retained by WebDownload when any downloads are in progress.
     @param delegate The WebDownloadDelegate to set as the download delegate.
 */    
 - (void)setDownloadDelegate: (id)delegate;
diff --git a/WebKit/WebView.subproj/WebView.h b/WebKit/WebView.subproj/WebView.h
index 054d947..7f78f60 100644
--- a/WebKit/WebView.subproj/WebView.h
+++ b/WebKit/WebView.subproj/WebView.h
@@ -155,6 +155,7 @@ extern NSString *WebElementLinkLabelKey;	// NSString of the text within the anch
 /*!
     @method setDownloadDelegate:
     @abstract Set the controller's WebDownloadDelegate.
+    @discussion The download delegate is retained by WebDownload when any downloads are in progress.
     @param delegate The WebDownloadDelegate to set as the download delegate.
 */    
 - (void)setDownloadDelegate: (id)delegate;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list