Gabriel Ivăncescu : vbscript: Return the item's disp when it does not have the SCRIPTITEM_CODEONLY flag, rather than the script dispatch.
Alexandre Julliard
julliard at winehq.org
Tue Feb 25 17:23:07 CST 2020
Module: wine
Branch: master
Commit: 02022849663b093bde596984842b422b266180d6
URL: https://source.winehq.org/git/wine.git/?a=commit;h=02022849663b093bde596984842b422b266180d6
Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date: Mon Feb 24 15:44:35 2020 +0200
vbscript: Return the item's disp when it does not have the SCRIPTITEM_CODEONLY flag, rather than the script dispatch.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 b0046cb3ae..27a4aee9bd 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 19689b5f6d..8536ee1776 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,
More information about the wine-cvs
mailing list