Reviewed by Anders.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Oct 2006 01:52:07 +0000 (01:52 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Oct 2006 01:52:07 +0000 (01:52 +0000)
        - fix http://bugs.webkit.org/show_bug.cgi?id=10328
          REGRESSION: frame leak reported by buildbot

        * WebCoreSupport/WebEditorClient.mm:
        (WebEditorClient::WebEditorClient): Don't retain the web view.
        (WebEditorClient::~WebEditorClient): Don't release the web view.
        (WebEditorClient::setWebView): Ditto.

        * WebCoreSupport/WebFrameBridge.m:
        (-[WebFrameBridge finishInitializingWithFrameName:view:]): Added. Common code for use by both
        init methods below.
        (-[WebFrameBridge initMainFrameWithPage:frameName:view:]): Changed to use new method.
        Also added comment pointing out design flaw -- we attach the client to the web view here,
        but we need to be sure to detach in case the web view is deallocated first.
        (-[WebFrameBridge initSubframeWithOwnerElement:frameName:view:]): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17199 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/ChangeLog
WebKit/WebCoreSupport/WebEditorClient.mm
WebKit/WebCoreSupport/WebFrameBridge.m

index 97161f574f8c1b5f128fe82d3bde732a650f29dd..b8d018cb668a78f2a7df4110fb72a3a0b016a144 100644 (file)
@@ -1,3 +1,23 @@
+2006-10-21  Darin Adler  <darin@apple.com>
+
+        Reviewed by Anders.
+
+        - fix http://bugs.webkit.org/show_bug.cgi?id=10328
+          REGRESSION: frame leak reported by buildbot
+
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::WebEditorClient): Don't retain the web view.
+        (WebEditorClient::~WebEditorClient): Don't release the web view.
+        (WebEditorClient::setWebView): Ditto.
+
+        * WebCoreSupport/WebFrameBridge.m:
+        (-[WebFrameBridge finishInitializingWithFrameName:view:]): Added. Common code for use by both
+        init methods below.
+        (-[WebFrameBridge initMainFrameWithPage:frameName:view:]): Changed to use new method.
+        Also added comment pointing out design flaw -- we attach the client to the web view here,
+        but we need to be sure to detach in case the web view is deallocated first.
+        (-[WebFrameBridge initSubframeWithOwnerElement:frameName:view:]): Ditto.
+
 2006-10-21  Darin Adler  <darin@apple.com>
 
         Reviewed by Adam.
index a2fd00eef7f5ac1a54314e97f16e5b430eb4574a..e55325295c7a5fcb8fc03844947c910653267db5 100644 (file)
 using namespace WebCore;
 
 WebEditorClient::WebEditorClient()
-    : m_webView(NULL
+    : m_webView(nil
 {
 }
 
 WebEditorClient::WebEditorClient(WebView* webView)
     : m_webView(webView) 
 {
-    [m_webView retain];
 }
 
 WebEditorClient::~WebEditorClient()
 {
-    [m_webView release];
 }
 
 void WebEditorClient::setWebView(WebView* webView)
 { 
-    if (m_webView != webView) {
-        [m_webView release];
-        m_webView = webView; 
-        [m_webView retain];
-    }
+    m_webView = webView; 
 }
 
 bool WebEditorClient::shouldDeleteRange(Range* range)
index ca4cd3b79def18ed00646fa7d1256e955a568f85..2df8a752113cfa5c79bad9febe1687fb846d99e6 100644 (file)
@@ -83,6 +83,7 @@
 #import <WebCore/WebLoader.h>
 #import <WebCore/WebSubresourceLoader.h>
 #import <WebKitSystemInterface.h>
+#import <wtf/RefPtr.h>
 
 // For compatibility only with old SPI. 
 @interface NSObject (OldWebPlugin)
@@ -117,32 +118,33 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
     return [(WebPageBridge *)[self page] webView];
 }
 
-- (id)initMainFrameWithPage:(WebPageBridge *)page frameName:(NSString *)name view:(WebFrameView *)view
+- (void)finishInitializingWithFrameName:(NSString *)name view:(WebFrameView *)view
 {
-    self = [super initMainFrameWithPage:page withEditorClient:new WebEditorClient([page webView])];
-    _frame = [[WebFrame alloc] _initWithWebFrameView:view webView:[self webView] bridge:self];
+    WebView *webView = [self webView];
 
+    _frame = [[WebFrame alloc] _initWithWebFrameView:view webView:webView bridge:self];
     ++WebBridgeCount;
 
     [self setName:name];
-    [self initializeSettings:[[self webView] _settings]];
-    [self setTextSizeMultiplier:[[self webView] textSizeMultiplier]];
+    [self initializeSettings:[webView _settings]];
+    [self setTextSizeMultiplier:[webView textSizeMultiplier]];
+}
 
+- (id)initMainFrameWithPage:(WebPageBridge *)page frameName:(NSString *)name view:(WebFrameView *)view
+{
+    // FIXME: Need to clear the WebView pointer in WebEditorClient when the WebView is deallocated.
+    self = [super initMainFrameWithPage:page withEditorClient:new WebEditorClient([page webView])];
+    [self finishInitializingWithFrameName:name view:view];
     return self;
 }
 
 - (id)initSubframeWithOwnerElement:(WebCoreElement *)ownerElement frameName:(NSString *)name view:(WebFrameView *)view
 {
-    WebEditorClient* editorClient = new WebEditorClient();
-    self = [super initSubframeWithOwnerElement:ownerElement withEditorClient:editorClient];
-    _frame = [[WebFrame alloc] _initWithWebFrameView:view webView:[self webView] bridge:self];
+    RefPtr<WebEditorClient> editorClient = new WebEditorClient;
+    self = [super initSubframeWithOwnerElement:ownerElement withEditorClient:editorClient.get()];
+    // FIXME: Need to clear the WebView pointer in WebEditorClient when the WebView is deallocated.
     editorClient->setWebView([self webView]);
-    ++WebBridgeCount;
-
-    [self setName:name];
-    [self initializeSettings:[[self webView] _settings]];
-    [self setTextSizeMultiplier:[[self webView] textSizeMultiplier]];
-
+    [self finishInitializingWithFrameName:name view:view];
     return self;
 }