diff --git a/ChangeLog b/ChangeLog index 3130c515d..b9b465922 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -2012-03-01 Richard Frith-Macdonald +2012-03-02 Richard Frith-Macdonald + + * Source/NSURLConnection.m: Compatibility fix for bug #35686 + In this case Cocoa breaks its own convention about delegates + not being retained, so we need to do the same. + +2012-03-02 Richard Frith-Macdonald * Headers/GNUstepBase/config.h.in: add missing ICU headers * Source/NSString.m: fix minor coding standard violations. diff --git a/Source/NSURLConnection.m b/Source/NSURLConnection.m index 38f11325d..6bf0d7cae 100644 --- a/Source/NSURLConnection.m +++ b/Source/NSURLConnection.m @@ -78,7 +78,7 @@ - (void) setConnection: (NSURLConnection*)c { - _connection = c; + _connection = c; // Not retained ... the connection retains us } - (void) connection: (NSURLConnection *)connection @@ -163,6 +163,7 @@ typedef struct { [this->_protocol stopLoading]; DESTROY(this->_protocol); + DESTROY(this->_delegate); } - (void) dealloc @@ -170,7 +171,8 @@ typedef struct if (this != 0) { [self cancel]; - RELEASE(this->_request); + DESTROY(this->_request); + DESTROY(this->_delegate); NSZoneFree([self zone], this); _NSURLConnectionInternal = 0; } @@ -216,7 +218,11 @@ typedef struct } } - this->_delegate = delegate; + /* According to bug #35686, Cocoa has a bizarre deviation from the convention + * that delegates are not retained here. For compatibility we retain the + * delegate and release it aggain when the operation is over. + */ + this->_delegate = [delegate retain]; this->_protocol = [[NSURLProtocol alloc] initWithRequest: this->_request cachedResponse: nil @@ -309,8 +315,8 @@ typedef struct NSRunLoop *loop; collector = [_NSURLConnectionDataCollector new]; - conn = [self alloc]; - conn = [conn initWithRequest: request delegate: [collector autorelease]]; + conn = [[self alloc] initWithRequest: request delegate: collector]; + [collector release]; // retained by connection [collector setConnection: conn]; loop = [NSRunLoop currentRunLoop]; while ([collector done] == NO)