mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 443878 - "XPConnect doesn't always suspend requests when switching contexts". r+sr=jst.
This commit is contained in:
parent
8ae1c8c8ef
commit
f6a7065993
@ -165,14 +165,6 @@ XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface)
|
||||
|
||||
// This is a method or attribute - we'll be needing a function object
|
||||
|
||||
// We need to use the safe context for this thread because we don't want
|
||||
// to parent the new (and cached forever!) function object to the current
|
||||
// JSContext's global object. That would be bad!
|
||||
|
||||
JSContext* cx = ccx.GetSafeJSContext();
|
||||
if(!cx)
|
||||
return JS_FALSE;
|
||||
|
||||
intN argc;
|
||||
intN flags;
|
||||
JSNative callback;
|
||||
@ -201,10 +193,31 @@ XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface)
|
||||
callback = XPC_WN_GetterSetter;
|
||||
}
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
// We need to use the safe context for this thread because we don't want
|
||||
// to parent the new (and cached forever!) function object to the current
|
||||
// JSContext's global object. That would be bad!
|
||||
|
||||
JSContext* cx = ccx.GetSafeJSContext();
|
||||
if(!cx)
|
||||
return JS_FALSE;
|
||||
|
||||
const char *memberName = iface->GetMemberName(ccx, this);
|
||||
|
||||
jsrefcount suspendDepth = 0;
|
||||
if(cx != ccx) {
|
||||
// Switching contexts, suspend the old and enter the new request.
|
||||
suspendDepth = JS_SuspendRequest(ccx);
|
||||
JS_BeginRequest(cx);
|
||||
}
|
||||
|
||||
JSFunction *fun = JS_NewFunction(cx, callback, argc, flags, nsnull,
|
||||
iface->GetMemberName(ccx, this));
|
||||
memberName);
|
||||
|
||||
if(suspendDepth) {
|
||||
JS_EndRequest(cx);
|
||||
JS_ResumeRequest(ccx, suspendDepth);
|
||||
}
|
||||
|
||||
if(!fun)
|
||||
return JS_FALSE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user