Commit 494b12b1 authored by ggaren's avatar ggaren

Reviewed by Anders Carlsson.

        
        Fixed <rdar://problem/5065399> REGRESSION: leaks in Frame::bindingRootObject 
        seen on buildbot

        The problem was that we were initializing the same WebScriptObject twice.
        This caused it to leak its original set of ivars.
        
        I think some refactoring could prevent this situation from arising in the
        first place, but I'm just adding a check at the call site for now, to do 
        the simplest thing.

        * bindings/objc/WebScriptObject.mm:
        (-[WebScriptObject _setImp:originRootObject:rootObject:]): Added ASSERTs
        against multiple calls.

        * bindings/objc/WebScriptObjectPrivate.h: Renamed _initializeWithObjectImp
        to setImp because "init" vs "initialize" was a too subtle indication that
        one was a Cocoa initializer and one was not.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20240 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 83eb5b71
2007-03-16 Geoffrey Garen <ggaren@apple.com>
Reviewed by Anders Carlsson.
Fixed <rdar://problem/5065399> REGRESSION: leaks in Frame::bindingRootObject
seen on buildbot
The problem was that we were initializing the same WebScriptObject twice.
This caused it to leak its original set of ivars.
I think some refactoring could prevent this situation from arising in the
first place, but I'm just adding a check at the call site for now, to do
the simplest thing.
* bindings/objc/WebScriptObject.mm:
(-[WebScriptObject _setImp:originRootObject:rootObject:]): Added ASSERTs
against multiple calls.
* bindings/objc/WebScriptObjectPrivate.h: Renamed _initializeWithObjectImp
to setImp because "init" vs "initialize" was a too subtle indication that
one was a Cocoa initializer and one was not.
2007-03-16 Lars Knoll <lars@trolltech.com>
don't use #import in .cpp files.
......
......@@ -120,7 +120,7 @@ void removeDOMWrapper(DOMObjectInternal* impl)
KJS::Bindings::RootObject* rootObject = frame->bindingRootObject();
[self _initializeWithObjectImp:scriptImp originRootObject:rootObject rootObject:rootObject];
[self _setImp:scriptImp originRootObject:rootObject rootObject:rootObject];
}
@end
......
......@@ -116,7 +116,8 @@ namespace WebCore {
id createDOMWrapper(KJS::JSObject* object, PassRefPtr<KJS::Bindings::RootObject> origin, PassRefPtr<KJS::Bindings::RootObject> current)
{
id wrapper = KJS::createDOMWrapper(object);
[wrapper _initializeWithObjectImp:object originRootObject:origin rootObject:current];
if (![wrapper _hasImp]) // new wrapper, not from cache
[wrapper _setImp:object originRootObject:origin rootObject:current];
return wrapper;
}
......
......@@ -65,8 +65,13 @@ static void _didExecute(WebScriptObject *obj)
func(exec, static_cast<JSObject*>([obj _rootObject]->interpreter()->globalObject()));
}
- (void)_initializeWithObjectImp:(JSObject*)imp originRootObject:(PassRefPtr<RootObject>)originRootObject rootObject:(PassRefPtr<RootObject>)rootObject
- (void)_setImp:(JSObject*)imp originRootObject:(PassRefPtr<RootObject>)originRootObject rootObject:(PassRefPtr<RootObject>)rootObject
{
// This function should only be called once, as a (possibly lazy) initializer.
ASSERT(!_private->imp);
ASSERT(!_private->rootObject);
ASSERT(!_private->originRootObject);
_private->imp = imp;
_private->rootObject = rootObject.releaseRef();
_private->originRootObject = originRootObject.releaseRef();
......@@ -75,13 +80,13 @@ static void _didExecute(WebScriptObject *obj)
_private->rootObject->gcProtect(imp);
}
- _initWithJSObject:(KJS::JSObject*)imp originRootObject:(PassRefPtr<KJS::Bindings::RootObject>)originRootObject rootObject:(PassRefPtr<KJS::Bindings::RootObject>)rootObject
- (id)_initWithJSObject:(KJS::JSObject*)imp originRootObject:(PassRefPtr<KJS::Bindings::RootObject>)originRootObject rootObject:(PassRefPtr<KJS::Bindings::RootObject>)rootObject
{
ASSERT(imp);
self = [super init];
_private = [[WebScriptObjectPrivate alloc] init];
[self _initializeWithObjectImp:imp originRootObject:originRootObject rootObject:rootObject];
[self _setImp:imp originRootObject:originRootObject rootObject:rootObject];
return self;
}
......@@ -95,6 +100,11 @@ static void _didExecute(WebScriptObject *obj)
return _private->imp;
}
- (BOOL)_hasImp
{
return _private->imp != nil;
}
- (RootObject*)_rootObject
{
return _private->rootObject && _private->rootObject->isValid() ? _private->rootObject : 0;
......
......@@ -11,11 +11,12 @@
@interface WebScriptObject (Private)
+ (id)_convertValueToObjcValue:(KJS::JSValue*)value originRootObject:(KJS::Bindings::RootObject*)originRootObject rootObject:(KJS::Bindings::RootObject*)rootObject;
- _init;
- _initWithJSObject:(KJS::JSObject*)imp originRootObject:(PassRefPtr<KJS::Bindings::RootObject>)originRootObject rootObject:(PassRefPtr<KJS::Bindings::RootObject>)rootObject;
- (void)_initializeWithObjectImp:(KJS::JSObject*)imp originRootObject:(PassRefPtr<KJS::Bindings::RootObject>)originRootObject rootObject:(PassRefPtr<KJS::Bindings::RootObject>)rootObject;
- (id)_init;
- (id)_initWithJSObject:(KJS::JSObject*)imp originRootObject:(PassRefPtr<KJS::Bindings::RootObject>)originRootObject rootObject:(PassRefPtr<KJS::Bindings::RootObject>)rootObject;
- (void)_setImp:(KJS::JSObject*)imp originRootObject:(PassRefPtr<KJS::Bindings::RootObject>)originRootObject rootObject:(PassRefPtr<KJS::Bindings::RootObject>)rootObject;
- (void)_initializeScriptDOMNodeImp;
- (KJS::JSObject *)_imp;
- (BOOL)_hasImp;
- (KJS::Bindings::RootObject*)_rootObject;
- (KJS::Bindings::RootObject*)_originRootObject;
@end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment