]> git.saurik.com Git - cydia.git/commitdiff
Simplify memory management of custom buttons.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 23 Feb 2011 10:41:38 +0000 (02:41 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 23 Feb 2011 10:48:53 +0000 (02:48 -0800)
UICaboodle/BrowserView.h
UICaboodle/BrowserView.mm

index 51cb345fed145c899b229001dd8aa90e53996a9d..32ef3b4ac91558b7212ac167aa506c42b7a20b9d 100644 (file)
@@ -10,6 +10,8 @@
 
 #import <JavaScriptCore/JavaScriptCore.h>
 
+#include "substrate.h"
+
 @class NSMutableArray;
 @class NSString;
 @class NSURL;
     NSMutableSet *loading_;
 
     // XXX: NSString * or UIImage *
-    id custom_;
-    NSString *style_;
+    _H<NSObject> custom_;
+    _H<NSString> style_;
 
-    WebScriptObject *function_;
+    _H<WebScriptObject> function_;
     WebScriptObject *closer_;
 
     float width_;
index 43f2905ac6494fa27ab9ad658cbc446f024f03f0..b5a7b9033d8dd362d31c4e7856a2d8d3d22c7aab 100644 (file)
@@ -483,13 +483,6 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se
     if (request_ != nil)
         [request_ release];
 
-    if (custom_ != nil)
-        [custom_ release];
-    if (style_ != nil)
-        [style_ release];
-
-    if (function_ != nil)
-        [function_ release];
     if (closer_ != nil)
         [closer_ release];
 
@@ -579,51 +572,18 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se
 }
 
 - (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
-    if (custom_ != nil)
-        [custom_ autorelease];
-    if (button == nil)
-        custom_ = nil;
-    else
-        custom_ = [[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:button]]] retain];
-
-    if (style_ != nil)
-        [style_ autorelease];
-    if (style == nil)
-        style_ = nil;
-    else
-        style_ = [style retain];
-
-    if (function_ != nil)
-        [function_ autorelease];
-    if (function == nil)
-        function_ = nil;
-    else
-        function_ = [function retain];
+    custom_ = button;
+    style_ = style;
+    function_ = function;
 
     [self performSelectorOnMainThread:@selector(applyRightButton) withObject:nil waitUntilDone:NO];
 }
 
 - (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
-    if (custom_ != nil)
-        [custom_ autorelease];
-    if (button == nil)
-        custom_ = nil;
-    else
-        custom_ = [button retain];
-
-    if (style_ != nil)
-        [style_ autorelease];
-    if (style == nil)
-        style_ = nil;
-    else
-        style_ = [style retain];
+    custom_ = button;
+    style_ = style;
+    function_ = function;
 
-    if (function_ != nil)
-        [function_ autorelease];
-    if (function == nil)
-        function_ = nil;
-    else
-        function_ = [function retain];
 
     [self performSelectorOnMainThread:@selector(applyRightButton) withObject:nil waitUntilDone:NO];
 }
@@ -840,9 +800,9 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se
 
     if ([frame parentFrame] == nil) {
         CYRelease(title_);
-        CYRelease(custom_);
-        CYRelease(style_);
-        CYRelease(function_);
+        custom_ = nil;
+        style_ = nil;
+        function_ = nil;
         CYRelease(closer_);
 
         // XXX: do we still need to do this?