diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2011-03-21 04:15:24 -0700 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2011-03-21 04:15:24 -0700 |
commit | 0291a3a646911ad30480ab925034ab7f765a8acf (patch) | |
tree | 885c5c9978aed9cdf7db60a209c13f52028a451b | |
parent | 9599dd2f2bfcc0a9997b6d90989fd02209bd73ee (diff) |
Fix underlying Apple UIWebViewWebViewDelegate on 2.x retain/release bug.
-rw-r--r-- | CyteKit/WebView.mm | 14 | ||||
-rw-r--r-- | iPhonePrivate.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/CyteKit/WebView.mm b/CyteKit/WebView.mm index 1329d4f..0e8ba71 100644 --- a/CyteKit/WebView.mm +++ b/CyteKit/WebView.mm @@ -118,6 +118,15 @@ } - (void) dealloc { + if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iPhoneOS_3_0) { + UIWebViewInternal *&_internal(MSHookIvar<UIWebViewInternal *>(self, "_internal")); + if (&_internal != NULL) { + UIWebViewWebViewDelegate *&webViewDelegate(MSHookIvar<UIWebViewWebViewDelegate *>(_internal, "webViewDelegate")); + if (&webViewDelegate != NULL) + [webViewDelegate _clearUIWebView]; + } + } + [super dealloc]; } @@ -353,6 +362,10 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se @end +static void $UIWebViewWebViewDelegate$_clearUIWebView(UIWebViewWebViewDelegate *self, SEL sel) { + MSHookIvar<UIWebView *>(self, "uiWebView") = nil; +} + __attribute__((__constructor__)) static void $() { if (Class $UIWebViewWebViewDelegate = objc_getClass("UIWebViewWebViewDelegate")) { class_addMethod($UIWebViewWebViewDelegate, @selector(webView:addMessageToConsole:), (IMP) &$UIWebViewWebViewDelegate$webView$addMessageToConsole$, "v16@0:4@8@12"); @@ -362,5 +375,6 @@ __attribute__((__constructor__)) static void $() { class_addMethod($UIWebViewWebViewDelegate, @selector(webView:didReceiveTitle:forFrame:), (IMP) &$UIWebViewWebViewDelegate$webView$didReceiveTitle$forFrame$, "v20@0:4@8@12@16"); class_addMethod($UIWebViewWebViewDelegate, @selector(webView:resource:willSendRequest:redirectResponse:fromDataSource:), (IMP) &$UIWebViewWebViewDelegate$webView$resource$willSendRequest$redirectResponse$fromDataSource$, "@28@0:4@8@12@16@20@24"); class_addMethod($UIWebViewWebViewDelegate, @selector(webViewClose:), (IMP) &$UIWebViewWebViewDelegate$webViewClose$, "v12@0:4@8"); + class_addMethod($UIWebViewWebViewDelegate, @selector(_clearUIWebView), (IMP) &$UIWebViewWebViewDelegate$_clearUIWebView, "v8@0:4"); } } diff --git a/iPhonePrivate.h b/iPhonePrivate.h index 8cc997a..cddfe9c 100644 --- a/iPhonePrivate.h +++ b/iPhonePrivate.h @@ -124,6 +124,9 @@ typedef enum { @interface UIWebViewWebViewDelegate : NSObject { @public UIWebView *uiWebView; } + +- (void) _clearUIWebView; + @end // }}} // @interface *Button : * {{{ |