From fac907b0a9553b7c983ed99cc304934e908a286a Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 25 Sep 2019 19:22:48 +0200 Subject: [PATCH] scrobj: Store script dispatch in script host. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/scrobj/scrobj.c | 18 ++++++++++++++++++ dlls/scrobj/tests/scrobj.c | 3 --- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/dlls/scrobj/scrobj.c b/dlls/scrobj/scrobj.c index 736dce9557f..946dd685f50 100644 --- a/dlls/scrobj/scrobj.c +++ b/dlls/scrobj/scrobj.c @@ -139,6 +139,7 @@ struct script_host IActiveScript *active_script; IActiveScriptParse *parser; + IDispatchEx *script_dispatch; struct scriptlet_instance *object; SCRIPTSTATE state; BOOL cloned; @@ -806,6 +807,11 @@ static void detach_script_hosts(struct list *hosts) if (host->state != SCRIPTSTATE_UNINITIALIZED) set_script_state(host, SCRIPTSTATE_UNINITIALIZED); list_remove(&host->entry); host->object = NULL; + if (host->script_dispatch) + { + IDispatchEx_Release(host->script_dispatch); + host->script_dispatch = NULL; + } if (host->parser) { IActiveScript_Close(host->active_script); @@ -1025,6 +1031,7 @@ static HRESULT create_scriptlet_instance(struct scriptlet_factory *factory, IDis { struct script_host *factory_host, *host; struct scriptlet_instance *obj; + IDispatch *script_dispatch; HRESULT hres; if (!(obj = heap_alloc_zero(sizeof(*obj)))) return E_OUTOFMEMORY; @@ -1053,6 +1060,17 @@ static HRESULT create_scriptlet_instance(struct scriptlet_factory *factory, IDis hres = IActiveScript_AddNamedItem(host->active_script, L"globals", SCRIPTITEM_ISVISIBLE); if (FAILED(hres)) break; + + hres = IActiveScript_GetScriptDispatch(host->active_script, NULL, &script_dispatch); + if (FAILED(hres)) return hres; + + hres = IDispatch_QueryInterface(script_dispatch, &IID_IDispatchEx, (void**)&host->script_dispatch); + IDispatch_Release(script_dispatch); + if (FAILED(hres)) + { + FIXME("IDispatchEx not supported by script engine\n"); + return hres; + } } if (SUCCEEDED(hres)) hres = parse_scripts(factory, &obj->hosts, TRUE); diff --git a/dlls/scrobj/tests/scrobj.c b/dlls/scrobj/tests/scrobj.c index e0a3ace7086..37b57693687 100644 --- a/dlls/scrobj/tests/scrobj.c +++ b/dlls/scrobj/tests/scrobj.c @@ -829,7 +829,6 @@ static void test_create_object(void) CHECK_CALLED(SetScriptSite); CHECK_CALLED(AddNamedItem_scriptlet); CHECK_CALLED(AddNamedItem_globals); - todo_wine CHECK_CALLED(GetScriptDispatch); todo_wine CHECK_CALLED(GetDispID_vbAddOne); @@ -1036,7 +1035,6 @@ static void test_create_object(void) CHECK_CALLED(SetScriptSite); CHECK_CALLED(AddNamedItem_scriptlet); CHECK_CALLED(AddNamedItem_globals); - todo_wine CHECK_CALLED(GetScriptDispatch); todo_wine CHECK_CALLED(GetDispID_vbAddOne); @@ -1074,7 +1072,6 @@ static void test_create_object(void) CHECK_CALLED(SetScriptSite); CHECK_CALLED(AddNamedItem_scriptlet); CHECK_CALLED(AddNamedItem_globals); - todo_wine CHECK_CALLED(GetScriptDispatch); todo_wine CHECK_CALLED(GetDispID_vbAddOne);