Bug 404402: Don't remove an XPCTraceableVariant from root set in dtor if it has already been done during unlinking. Patch by peterv. r/sr=sicking

This commit is contained in:
jonas@sicking.cc 2007-11-04 18:07:09 -08:00
parent 7aaaa8940c
commit 6c25f1dfd7

View File

@ -63,19 +63,20 @@ XPCVariant::XPCVariant(jsval aJSVal)
XPCTraceableVariant::~XPCTraceableVariant()
{
NS_ASSERTION(JSVAL_IS_TRACEABLE(mJSVal), "Must be tracaeble");
NS_ASSERTION(JSVAL_IS_GCTHING(mJSVal), "Must be traceable or unlinked");
// If mJSVal is JSVAL_STRING, we don't need to clean anything up;
// simply removing the string from the root set is good.
if(!JSVAL_IS_STRING(mJSVal))
nsVariant::Cleanup(&mData);
RemoveFromRootSet(nsXPConnect::GetRuntime()->GetJSRuntime());
if(!JSVAL_IS_NULL(mJSVal))
RemoveFromRootSet(nsXPConnect::GetRuntime()->GetJSRuntime());
}
void XPCTraceableVariant::TraceJS(JSTracer* trc)
{
NS_ASSERTION(JSVAL_IS_TRACEABLE(mJSVal), "Must be tracaeble");
NS_ASSERTION(JSVAL_IS_TRACEABLE(mJSVal), "Must be traceable");
JS_SET_TRACING_DETAILS(trc, PrintTraceName, this, 0);
JS_CallTracer(trc, JSVAL_TO_TRACEABLE(mJSVal), JSVAL_TRACE_KIND(mJSVal));
}