Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/vbscript/interp.c | 4 +++- dlls/vbscript/tests/vbscript.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index b0046cb..27a4aee 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -1527,7 +1527,9 @@ static HRESULT interp_me(exec_ctx_t *ctx) if(ctx->vbthis) disp = (IDispatch*)&ctx->vbthis->IDispatchEx_iface; else if(ctx->code->named_item) - disp = (IDispatch*)&ctx->code->named_item->script_obj->IDispatchEx_iface; + 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 diff --git a/dlls/vbscript/tests/vbscript.c b/dlls/vbscript/tests/vbscript.c index 19689b5..8536ee1 100644 --- a/dlls/vbscript/tests/vbscript.c +++ b/dlls/vbscript/tests/vbscript.c @@ -1858,6 +1858,15 @@ static void test_named_items(void)
hres = IActiveScript_GetScriptDispatch(script, L"visibleCodeItem", &disp); ok(hres == S_OK, "GetScriptDispatch returned: %08x\n", hres); + SET_EXPECT(OnEnterScript); + SET_EXPECT(OnLeaveScript); + hres = IActiveScriptParse_ParseScriptText(parse, L"me", L"visibleCodeItem", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL); + ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); + ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == disp, + "Unexpected 'me': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var)); + VariantClear(&var); + CHECK_CALLED(OnEnterScript); + CHECK_CALLED(OnLeaveScript); IDispatch_Release(disp);
SET_EXPECT(GetItemInfo_visible_code); @@ -1993,6 +2002,15 @@ static void test_named_items(void) CHECK_CALLED(OnLeaveScript); SET_EXPECT(OnEnterScript); SET_EXPECT(OnLeaveScript); + hres = IActiveScriptParse_ParseScriptText(parse, L"me", L"globalItem", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL); + ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); + ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == &global_named_item, + "Unexpected 'me': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var)); + VariantClear(&var); + CHECK_CALLED(OnEnterScript); + CHECK_CALLED(OnLeaveScript); + SET_EXPECT(OnEnterScript); + SET_EXPECT(OnLeaveScript); hres = IActiveScriptParse_ParseScriptText(parse, L"me", L"codeOnlyItem", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL); ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == (IDispatch*)script_disp2,