]> git.saurik.com Git - cydia.git/blobdiff - UICaboodle/BrowserView.m
Fixed memory retain issue in _H<> and a crash bug in sources_ (causing nils).
[cydia.git] / UICaboodle / BrowserView.m
index 0161c5fbd01f07ad4b1e46ee217a4e8121519fd9..10cc19376a28f83930195cf501ccc7670e7aa06e 100644 (file)
 }
 
 - (NSString *) stringWithFormat:(NSString *)format arguments:(WebScriptObject *)arguments {
-    NSLog(@"SWF:\"%@\" A:%@", format, arguments);
+    //NSLog(@"SWF:\"%@\" A:%@", format, [arguments description]);
     unsigned count([arguments count]);
     id values[count];
     for (unsigned i(0); i != count; ++i)
 - (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],