From 46d3a5cfc2959b65fef514faa666d735b91afbc6 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 23 Feb 2011 02:41:38 -0800 Subject: Simplify memory management of custom buttons. --- UICaboodle/BrowserView.h | 8 ++++--- UICaboodle/BrowserView.mm | 58 ++++++++--------------------------------------- 2 files changed, 14 insertions(+), 52 deletions(-) (limited to 'UICaboodle') diff --git a/UICaboodle/BrowserView.h b/UICaboodle/BrowserView.h index 51cb345..32ef3b4 100644 --- a/UICaboodle/BrowserView.h +++ b/UICaboodle/BrowserView.h @@ -10,6 +10,8 @@ #import +#include "substrate.h" + @class NSMutableArray; @class NSString; @class NSURL; @@ -77,10 +79,10 @@ NSMutableSet *loading_; // XXX: NSString * or UIImage * - id custom_; - NSString *style_; + _H custom_; + _H style_; - WebScriptObject *function_; + _H function_; WebScriptObject *closer_; float width_; diff --git a/UICaboodle/BrowserView.mm b/UICaboodle/BrowserView.mm index 43f2905..b5a7b90 100644 --- a/UICaboodle/BrowserView.mm +++ b/UICaboodle/BrowserView.mm @@ -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? -- cgit v1.2.3