diff -r 10e98eab6f85 -r a359256acfc6 webengine/device/src/DeviceLiwResult.cpp --- a/webengine/device/src/DeviceLiwResult.cpp Fri Jul 03 15:54:40 2009 +0100 +++ b/webengine/device/src/DeviceLiwResult.cpp Thu Aug 27 07:44:59 2009 +0300 @@ -48,15 +48,10 @@ DeviceLiwResult::DeviceLiwResult( JSValue* proto) : JSObject(proto) { - m_privateData = new DeviceLiwResultPrivate(); - if (!m_privateData) - m_valid = false; - else - { - m_valid = true; - // protect this object - KJS::Collector::protect(this); - } + m_valid = EFalse; + m_privateData = new DeviceLiwResultPrivate(this); + if ( m_privateData ) + m_valid = ETrue; } // ---------------------------------------------------------------------------- @@ -66,75 +61,21 @@ // DeviceLiwResult::~DeviceLiwResult() { - // only can be called by garbage collection after the - // DeviceLiwResult::Close() was called + Close(); } // ---------------------------------------------------------------------------- // DeviceLiwResult::Close // // ---------------------------------------------------------------------------- -void DeviceLiwResult::Close( ExecState* exec, bool unmark ) +void DeviceLiwResult::Close() { - - // avoid double close if(!m_valid) - { - if(unmark) - { - // unprotect this to allow the garbage collection to release this jsobject - KJS::Collector::unprotect(this); - } return; - } - - // close thDeviceLiwIterable - if ( exec ) - { - PropertyNameArray propertyNames; - this->getPropertyNames( exec, propertyNames ); - unsigned size = static_cast(propertyNames.size()); - - for (unsigned i = 0; i < size; i++) - { - JSValue * jsvalue = this->get( exec, propertyNames[i] ); - if(jsvalue->isObject()) - { - JSObject * prop = jsvalue->toObject( exec ); - if (prop && prop->inherits( &DeviceLiwIterable::info )) - { - (static_cast(prop))->Close(exec, true); - } - } - } - } - + + m_valid = EFalse; delete m_privateData; m_privateData = NULL; - m_valid = false; - - if(unmark) - { - // unprotect this to allow the garbage collection to release this jsobject - KJS::Collector::unprotect(this); - } - } - -// ---------------------------------------------------------------------------- -// DeviceLiwResult::QuickClose -// -// ---------------------------------------------------------------------------- -void DeviceLiwResult::quickClose() - { - if(!m_valid) - return - - delete m_privateData; - m_privateData = NULL; - m_valid = false; - - // unprotect this to allow the garbage collection to release this jsobject - KJS::Collector::unprotect(this); } // ---------------------------------------------------------------------------- @@ -238,18 +179,20 @@ // DeviceLiwIterablePrivate constructor // // --------------------------------------------------------------------------- -DeviceLiwResultPrivate::DeviceLiwResultPrivate() +DeviceLiwResultPrivate::DeviceLiwResultPrivate(DeviceLiwResult* jsobj) { - // currently, do nothing + m_jsobj = jsobj; } // --------------------------------------------------------------------------- // DeviceLiwMapPrivate::Close // // --------------------------------------------------------------------------- -void DeviceLiwResultPrivate::Close() +DeviceLiwResultPrivate::~DeviceLiwResultPrivate() { - // currently, do nothing + // invalid the DeviceLiwResult + if (m_jsobj) + m_jsobj->m_valid = EFalse; } // ---------------------------------------------------------------------------- @@ -278,7 +221,7 @@ if ( m_func == DeviceLiwResult::close ) { - result->Close(exec, false); + result->Close(); } return jsUndefined(); }