scrobj: Store script dispatch in script host.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-09-25 19:22:48 +02:00 committed by Alexandre Julliard
parent 3013d5d1e7
commit fac907b0a9
2 changed files with 18 additions and 3 deletions

View File

@ -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);

View File

@ -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);