summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-03-21 04:27:21 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2011-03-21 04:27:21 -0700
commit8b74eaff1f16b230665b91ba7b34b3c90ede5f8c (patch)
tree4a307e9b711dbca436b0617d92721a620323a445
parent2713be8e0bb9310f23e786a45429b422f6911db3 (diff)
Don't lose track of network activity during memory warnings.
-rw-r--r--CyteKit/WebViewController.mm26
1 files changed, 21 insertions, 5 deletions
diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm
index 2298d75..a38a8d0 100644
--- a/CyteKit/WebViewController.mm
+++ b/CyteKit/WebViewController.mm
@@ -148,14 +148,21 @@ float CYScrollViewDecelerationRateNormal;
return true;
}
+- (void) releaseNetworkActivityIndicator {
+ if ([loading_ count] != 0) {
+ [loading_ removeAllObjects];
+
+ if ([self retainsNetworkActivityIndicator])
+ [delegate_ releaseNetworkActivityIndicator];
+ }
+}
+
- (void) dealloc {
#if LogBrowser
NSLog(@"[CyteWebViewController dealloc]");
#endif
- if ([loading_ count] != 0)
- if ([self retainsNetworkActivityIndicator])
- [delegate_ releaseNetworkActivityIndicator];
+ [self releaseNetworkActivityIndicator];
[super dealloc];
}
@@ -352,7 +359,11 @@ float CYScrollViewDecelerationRateNormal;
}
- (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
- [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
+ NSValue *object([NSValue valueWithNonretainedObject:frame]);
+ if (![loading_ containsObject:object])
+ return;
+ [loading_ removeObject:object];
+
[self _didFinishLoading];
if ([[error domain] isEqualToString:NSURLErrorDomain] && [error code] == NSURLErrorCancelled)
@@ -500,7 +511,10 @@ float CYScrollViewDecelerationRateNormal;
}
- (void) webView:(WebView *)view didFinishLoadForFrame:(WebFrame *)frame {
- [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
+ NSValue *object([NSValue valueWithNonretainedObject:frame]);
+ if (![loading_ containsObject:object])
+ return;
+ [loading_ removeObject:object];
if ([frame parentFrame] == nil) {
if (DOMDocument *document = [frame DOMDocument])
@@ -906,6 +920,8 @@ float CYScrollViewDecelerationRateNormal;
webview_ = nil;
scroller_ = nil;
+ [self releaseNetworkActivityIndicator];
+
[super releaseSubviews];
}