Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index 376af3c..74d33fc 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -51,6 +51,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msscript);
struct ScriptControl; typedef struct ConnectionPoint ConnectionPoint; +typedef struct ScriptHost ScriptHost;
struct ConnectionPoint { IConnectionPoint IConnectionPoint_iface; @@ -68,9 +69,11 @@ struct named_item { typedef struct { IScriptModule IScriptModule_iface; LONG ref; + + ScriptHost *host; } ScriptModule;
-typedef struct ScriptHost { +struct ScriptHost { IActiveScriptSite IActiveScriptSite_iface; IActiveScriptSiteWindow IActiveScriptSiteWindow_iface; IServiceProvider IServiceProvider_iface; @@ -83,7 +86,7 @@ typedef struct ScriptHost { CLSID clsid;
struct list named_items; -} ScriptHost; +};
struct ScriptControl { IScriptControl IScriptControl_iface; @@ -608,7 +611,11 @@ static ULONG WINAPI ScriptModule_Release(IScriptModule *iface) TRACE("(%p) ref=%d\n", This, ref);
if (!ref) + { + if (This->host) + IActiveScriptSite_Release(&This->host->IActiveScriptSite_iface); heap_free(This); + }
return ref; } @@ -762,6 +769,7 @@ static ScriptModule *create_module(void)
module->IScriptModule_iface.lpVtbl = &ScriptModuleVtbl; module->ref = 1; + module->host = NULL; return module; }
@@ -1193,7 +1201,9 @@ static HRESULT WINAPI ScriptControl_put_Language(IScriptControl *iface, BSTR lan { ScriptControl *This = impl_from_IScriptControl(iface); ScriptModule **modules; + unsigned int i; CLSID clsid; + HRESULT hr;
TRACE("(%p)->(%s)\n", This, debugstr_w(language));
@@ -1214,6 +1224,12 @@ static HRESULT WINAPI ScriptControl_put_Language(IScriptControl *iface, BSTR lan release_script_engine(This->host); IActiveScriptSite_Release(&This->host->IActiveScriptSite_iface); This->host = NULL; + + for (i = 0; i < This->module_count; i++) + { + IActiveScriptSite_Release(&This->modules[i]->host->IActiveScriptSite_iface); + This->modules[i]->host = NULL; + } }
release_modules(This); @@ -1223,7 +1239,12 @@ static HRESULT WINAPI ScriptControl_put_Language(IScriptControl *iface, BSTR lan if (!language) return S_OK;
- return init_script_host(&clsid, &This->host); + hr = init_script_host(&clsid, &This->host); + if (FAILED(hr)) return hr; + + modules[0]->host = This->host; + IActiveScriptSite_AddRef(&modules[0]->host->IActiveScriptSite_iface); + return S_OK; }
static HRESULT WINAPI ScriptControl_get_State(IScriptControl *iface, ScriptControlStates *p)