Commit 229a583c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Move create_script_disp call to SetScriptSite.

parent cbf62049
......@@ -2860,14 +2860,6 @@ void detach_global_objects(script_ctx_t *ctx)
IDispatch_Release(&ctx->global_obj->IDispatch_iface);
ctx->global_obj = NULL;
}
if(ctx->script_obj) {
ScriptDisp *script_obj = ctx->script_obj;
ctx->script_obj = NULL;
script_obj->ctx = NULL;
IDispatchEx_Release(&script_obj->IDispatchEx_iface);
}
}
HRESULT init_global(script_ctx_t *ctx)
......@@ -2878,9 +2870,5 @@ HRESULT init_global(script_ctx_t *ctx)
if(FAILED(hres))
return hres;
hres = create_script_disp(ctx, &ctx->script_obj);
if(FAILED(hres))
return hres;
return create_builtin_dispatch(ctx, err_props, ARRAY_SIZE(err_props), &ctx->err_obj);
}
......@@ -182,6 +182,14 @@ static void release_script(script_ctx_t *ctx)
ctx->site = NULL;
}
if(ctx->script_obj) {
ScriptDisp *script_obj = ctx->script_obj;
ctx->script_obj = NULL;
script_obj->ctx = NULL;
IDispatchEx_Release(&script_obj->IDispatchEx_iface);
}
detach_global_objects(ctx);
heap_pool_free(&ctx->heap);
heap_pool_init(&ctx->heap);
......@@ -415,6 +423,10 @@ static HRESULT WINAPI VBScript_SetScriptSite(IActiveScript *iface, IActiveScript
if(InterlockedCompareExchange(&This->thread_id, GetCurrentThreadId(), 0))
return E_UNEXPECTED;
hres = create_script_disp(This->ctx, &This->ctx->script_obj);
if(FAILED(hres))
return hres;
This->ctx->site = pass;
IActiveScriptSite_AddRef(This->ctx->site);
......@@ -514,7 +526,7 @@ static HRESULT WINAPI VBScript_AddNamedItem(IActiveScript *iface, LPCOLESTR pstr
TRACE("(%p)->(%s %x)\n", This, debugstr_w(pstrName), dwFlags);
if(This->thread_id != GetCurrentThreadId() || This->state == SCRIPTSTATE_CLOSED)
if(This->thread_id != GetCurrentThreadId() || !This->ctx->site)
return E_UNEXPECTED;
if(dwFlags & SCRIPTITEM_GLOBALMEMBERS) {
......
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