vbscript: Lookup host global object in interp_me instead of storing it in script context.

Inspired by patch by Gabriel Ivăncescu.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-02-28 17:26:21 +01:00 committed by Alexandre Julliard
parent 3d23f095bf
commit b4e89eec17
3 changed files with 13 additions and 18 deletions

View File

@ -1524,16 +1524,23 @@ static HRESULT interp_me(exec_ctx_t *ctx)
TRACE("\n");
if(ctx->vbthis)
if(ctx->vbthis) {
disp = (IDispatch*)&ctx->vbthis->IDispatchEx_iface;
else if(ctx->code->named_item)
}else if(ctx->code->named_item) {
disp = (ctx->code->named_item->flags & SCRIPTITEM_CODEONLY)
? (IDispatch*)&ctx->code->named_item->script_obj->IDispatchEx_iface
: ctx->code->named_item->disp;
else if(ctx->script->host_global)
disp = ctx->script->host_global;
else
}else {
named_item_t *item;
disp = NULL;
LIST_FOR_EACH_ENTRY(item, &ctx->script->named_items, named_item_t, entry) {
if(!(item->flags & SCRIPTITEM_GLOBALMEMBERS)) continue;
disp = item->disp;
break;
}
if(!disp)
disp = (IDispatch*)&ctx->script->script_obj->IDispatchEx_iface;
}
IDispatch_AddRef(disp);
V_VT(&v) = VT_DISPATCH;

View File

@ -283,11 +283,6 @@ static void release_script(script_ctx_t *ctx)
release_named_item(iter);
}
if(ctx->host_global) {
IDispatch_Release(ctx->host_global);
ctx->host_global = NULL;
}
if(ctx->secmgr) {
IInternetHostSecurityManager_Release(ctx->secmgr);
ctx->secmgr = NULL;
@ -675,11 +670,6 @@ static HRESULT WINAPI VBScript_AddNamedItem(IActiveScript *iface, LPCOLESTR pstr
WARN("object does not implement IDispatch\n");
return hres;
}
if(This->ctx->host_global)
IDispatch_Release(This->ctx->host_global);
IDispatch_AddRef(disp);
This->ctx->host_global = disp;
}
item = heap_alloc(sizeof(*item));

View File

@ -186,8 +186,6 @@ struct _script_ctx_t {
IInternetHostSecurityManager *secmgr;
DWORD safeopt;
IDispatch *host_global;
ScriptDisp *script_obj;
BuiltinDisp *global_obj;