]> git.saurik.com Git - cydia.git/commitdiff
Various stability issues.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 20 Apr 2009 22:36:30 +0000 (22:36 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 30 Sep 2010 07:13:14 +0000 (07:13 +0000)
Cydia.mm
UICaboodle/BrowserView.m

index a0df37c26376e52983239a6fb1497f4123c8aaba..e10a7d50c8fe52d3ff7c8227e9c0e909decd0e00 100644 (file)
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -7204,7 +7204,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     ManageView *manage_;
     SearchView *search_;
 
-    PackageView *package_;
+    NSMutableArray *details_;
 }
 
 @end
@@ -7584,19 +7584,30 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 }
 
 - (void) setPackageView:(PackageView *)view {
-    if (package_ == nil)
-        package_ = [view retain];
+    WebThreadLock();
+    [view setPackage:nil];
+    if ([details_ count] < 3)
+        [details_ addObject:view];
+    WebThreadUnlock();
+}
+
+- (PackageView *) _packageView {
+    return [[[PackageView alloc] initWithBook:book_ database:database_] autorelease];
 }
 
 - (PackageView *) packageView {
     PackageView *view;
+    size_t count([details_ count]);
 
-    if (package_ == nil)
-        view = [[[PackageView alloc] initWithBook:book_ database:database_] autorelease];
-    else {
-        return package_;
-        view = [package_ autorelease];
-        package_ = nil;
+    if (count == 0) {
+        view = [self _packageView];
+      renew:
+        [details_ addObject:[self _packageView]];
+    } else {
+        view = [[[details_ lastObject] retain] autorelease];
+        [details_ removeLastObject];
+        if (count == 1)
+            goto renew;
     }
 
     return view;
@@ -7734,7 +7745,9 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
         withClass:[ManageView class]
     ] retain];
 
-    [self setPackageView:[self packageView]];
+    details_ = [[NSMutableArray alloc] initWithCapacity:4];
+    [details_ addObject:[self _packageView]];
+    [details_ addObject:[self _packageView]];
 
     PrintTimes();
 
index b0b04fb225aff5ad04dd7a27d76b32edd27049fc..10cc19376a28f83930195cf501ccc7670e7aa06e 100644 (file)
 - (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
     if (![self _allowJavaScriptPanel])
         return;
-
-    // WTR: [self retain];
+    [self retain];
 
     UIActionSheet *sheet = [[[UIActionSheet alloc]
         initWithTitle:nil
 - (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
     if (![self _allowJavaScriptPanel])
         return NO;
+    [self retain];
 
     UIActionSheet *sheet = [[[UIActionSheet alloc]
         initWithTitle:nil
 
     NSNumber *confirm([confirm_ autorelease]);
     confirm_ = nil;
+
+    [self autorelease];
     return [confirm boolValue];
 }
 
 }
 
 - (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
-    [loading_ addObject:frame];
+    if ([loading_ count] == 0)
+        [self retain];
+    [loading_ addObject:[NSValue valueWithNonretainedObject:frame]];
 
     if ([frame parentFrame] == nil) {
         [webview_ resignFirstResponder];
 }
 
 - (void) _finishLoading {
-    if (reloading_ || [loading_ count] != 0)
+    size_t count([loading_ count]);
+    if (count == 0)
+        [self autorelease];
+    if (reloading_ || count != 0)
         return;
     if (finish_ != nil)
         [self callFunction:finish_];
 }
 
 - (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
-    [loading_ removeObject:frame];
-
+    [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
     [self _finishLoading];
 
     if ([frame parentFrame] == nil) {
 }
 
 - (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
-    [loading_ removeObject:frame];
-    if (reloading_)
-        return;
+    if ([frame parentFrame] == nil)
+        [self autorelease];
 
+    [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
     [self _finishLoading];
 
+    if (reloading_)
+        return;
+
     if ([frame parentFrame] == nil) {
         [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
             [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],