Bug 552686 JS_GetFrameThis seems to require a JSContext these days when it calls some xpconnect wrapper that gets a thisObject
authortimeless@mozdev.org
Tue, 25 May 2010 04:11:47 +0300
changeset 47248 b3142fc39e4506f956d716c0faf1ec1925f22948
parent 47247 360f7ec9f2feb071144681b7ac1be5ba9c8837d8
child 47249 4fe78510f911e5be96e7f81666ab7279653ad3e3
push idunknown
push userunknown
push dateunknown
bugs552686
milestone2.0b2pre
Bug 552686 JS_GetFrameThis seems to require a JSContext these days when it calls some xpconnect wrapper that gets a thisObject r=jorendorff
js/jsd/jsd_stak.c
--- a/js/jsd/jsd_stak.c
+++ b/js/jsd/jsd_stak.c
@@ -115,16 +115,17 @@ jsd_NewThreadState(JSDContext* jsdc, JSC
     if( ! jsdthreadstate )
         return NULL;
 
     jsdthreadstate->context = cx;
     jsdthreadstate->thread = JSD_CURRENT_THREAD();
     JS_INIT_CLIST(&jsdthreadstate->stack);
     jsdthreadstate->stackDepth = 0;
 
+    JS_BeginRequest(jsdthreadstate->context);
     while( NULL != (fp = JS_FrameIterator(cx, &iter)) )
     {
         JSScript* script = JS_GetFrameScript(cx, fp);
         jsuword  pc = (jsuword) JS_GetFramePC(cx, fp);
 
         /*
          * don't construct a JSDStackFrame for dummy frames (those without a
          * |this| object, or native frames, if JSD_INCLUDE_NATIVE_FRAMES
@@ -143,20 +144,22 @@ jsd_NewThreadState(JSDContext* jsdc, JSC
                  frame->jsdscript && !JSD_IS_DEBUG_ENABLED(jsdc, frame->jsdscript)))
             {
                 /*
                  * if we failed to create the first frame, or the top frame
                  * is not enabled for debugging, fail the entire thread state.
                  */
                 JS_INIT_CLIST(&jsdthreadstate->links);
                 jsd_DestroyThreadState(jsdc, jsdthreadstate);
+                JS_EndRequest(jsdthreadstate->context);
                 return NULL;
             }
         }
     }
+    JS_EndRequest(jsdthreadstate->context);
 
     if (jsdthreadstate->stackDepth == 0)
     {
         free(jsdthreadstate);
         return NULL;
     }
     
     JSD_LOCK_THREADSTATES(jsdc);
@@ -334,17 +337,19 @@ jsd_GetThisForStackFrame(JSDContext* jsd
                          JSDStackFrameInfo* jsdframe)
 {
     JSObject* obj;
     JSDValue* jsdval = NULL;
     JSD_LOCK_THREADSTATES(jsdc);
 
     if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
     {
+        JS_BeginRequest(jsdthreadstate->context);
         obj = JS_GetFrameThis(jsdthreadstate->context, jsdframe->fp);
+        JS_EndRequest(jsdthreadstate->context);
         if(obj)
             jsdval = JSD_NewValue(jsdc, OBJECT_TO_JSVAL(obj));
     }
 
     JSD_UNLOCK_THREADSTATES(jsdc);
     return jsdval;
 }