Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index cd0a21b..d966869 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -68,6 +68,7 @@ struct named_item {
struct module { BSTR name; + IDispatch *script_dispatch; ScriptModule *object; };
@@ -86,7 +87,6 @@ typedef struct ScriptHost {
IActiveScript *script; IActiveScriptParse *parse; - IDispatch *script_dispatch; SCRIPTSTATE script_state; CLSID clsid;
@@ -230,14 +230,15 @@ static struct named_item *host_get_named_item(ScriptHost *host, const WCHAR *nam return NULL; }
-static HRESULT get_script_dispatch(struct ScriptControl *control, IDispatch **disp) +static HRESULT get_script_dispatch(ScriptControl *control, struct module *module, IDispatch **disp) { - if (!control->host->script_dispatch) + if (!module->script_dispatch) { - HRESULT hr = IActiveScript_GetScriptDispatch(control->host->script, NULL, &control->host->script_dispatch); + HRESULT hr = IActiveScript_GetScriptDispatch(control->host->script, + module->name, &module->script_dispatch); if (FAILED(hr)) return hr; } - *disp = control->host->script_dispatch; + *disp = module->script_dispatch; return S_OK; }
@@ -414,10 +415,7 @@ static void release_script_engine(ScriptHost *host)
if (host->parse) IActiveScriptParse_Release(host->parse); - if (host->script_dispatch) - IDispatch_Release(host->script_dispatch);
- host->script_dispatch = NULL; host->parse = NULL; host->script = NULL;
@@ -635,6 +633,8 @@ static void release_modules(ScriptControl *control) module->object->control = NULL; IScriptControl_Release(&control->IScriptControl_iface); } + if (module->script_dispatch) + IDispatch_Release(module->script_dispatch); SysFreeString(module->name); } while (i--);
@@ -1047,6 +1047,7 @@ static HRESULT WINAPI ScriptModuleCollection_Add(IScriptModuleCollection *iface, module = &This->modules[This->num_modules]; if (!(module->name = SysAllocString(name))) return E_OUTOFMEMORY; + module->script_dispatch = NULL; module->object = NULL;
hr = grab_module_object(This, This->num_modules); @@ -1106,7 +1107,6 @@ static HRESULT init_script_host(const CLSID *clsid, ScriptHost **ret) host->ref = 1; host->script = NULL; host->parse = NULL; - host->script_dispatch = NULL; host->clsid = *clsid; list_init(&host->named_items);
@@ -1602,11 +1602,12 @@ static HRESULT WINAPI ScriptControl_Run(IScriptControl *iface, BSTR procedure_na V_VT(res) = VT_EMPTY; if (sa->cDims == 0) return DISP_E_BADINDEX; if (!(sa->fFeatures & FADF_VARIANT)) return DISP_E_BADVARTYPE; + if (!This->modules) return E_FAIL;
hr = start_script(This); if (FAILED(hr)) return hr;
- hr = get_script_dispatch(This, &disp); + hr = get_script_dispatch(This, &This->modules[0], &disp); if (FAILED(hr)) return hr;
hr = IDispatch_GetIDsOfNames(disp, &IID_NULL, &procedure_name, 1, LOCALE_USER_DEFAULT, &dispid);