msscript.ocx: Move modules_count to the Script Host.
Based on patch by Gabriel Ivăncescu. Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
01143089f0
commit
5a6ac3aac1
|
@ -82,6 +82,8 @@ typedef struct ScriptHost {
|
||||||
SCRIPTSTATE script_state;
|
SCRIPTSTATE script_state;
|
||||||
CLSID clsid;
|
CLSID clsid;
|
||||||
|
|
||||||
|
unsigned int module_count;
|
||||||
|
|
||||||
struct list named_items;
|
struct list named_items;
|
||||||
} ScriptHost;
|
} ScriptHost;
|
||||||
|
|
||||||
|
@ -111,7 +113,6 @@ struct ScriptControl {
|
||||||
DWORD view_sink_flags;
|
DWORD view_sink_flags;
|
||||||
|
|
||||||
/* modules */
|
/* modules */
|
||||||
unsigned int module_count;
|
|
||||||
ScriptModule **modules;
|
ScriptModule **modules;
|
||||||
IScriptModuleCollection IScriptModuleCollection_iface;
|
IScriptModuleCollection IScriptModuleCollection_iface;
|
||||||
|
|
||||||
|
@ -770,10 +771,9 @@ static void release_modules(ScriptControl *control)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < control->module_count; i++)
|
for (i = 0; i < control->host->module_count; i++)
|
||||||
IScriptModule_Release(&control->modules[i]->IScriptModule_iface);
|
IScriptModule_Release(&control->modules[i]->IScriptModule_iface);
|
||||||
|
|
||||||
control->module_count = 0;
|
|
||||||
heap_free(control->modules);
|
heap_free(control->modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -896,8 +896,9 @@ static HRESULT WINAPI ScriptModuleCollection_get_Count(IScriptModuleCollection *
|
||||||
TRACE("(%p)->(%p)\n", This, plCount);
|
TRACE("(%p)->(%p)\n", This, plCount);
|
||||||
|
|
||||||
if (!plCount) return E_POINTER;
|
if (!plCount) return E_POINTER;
|
||||||
|
if (!This->host) return E_FAIL;
|
||||||
|
|
||||||
*plCount = This->module_count;
|
*plCount = This->host->module_count;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -945,6 +946,7 @@ static HRESULT init_script_host(const CLSID *clsid, ScriptHost **ret)
|
||||||
host->parse = NULL;
|
host->parse = NULL;
|
||||||
host->script_dispatch = NULL;
|
host->script_dispatch = NULL;
|
||||||
host->clsid = *clsid;
|
host->clsid = *clsid;
|
||||||
|
host->module_count = 1;
|
||||||
list_init(&host->named_items);
|
list_init(&host->named_items);
|
||||||
|
|
||||||
hr = CoCreateInstance(&host->clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
hr = CoCreateInstance(&host->clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
||||||
|
@ -1068,8 +1070,10 @@ static ULONG WINAPI ScriptControl_Release(IScriptControl *iface)
|
||||||
if (This->site)
|
if (This->site)
|
||||||
IOleClientSite_Release(This->site);
|
IOleClientSite_Release(This->site);
|
||||||
if (This->host)
|
if (This->host)
|
||||||
release_script_engine(This->host);
|
{
|
||||||
release_modules(This);
|
release_modules(This);
|
||||||
|
release_script_engine(This->host);
|
||||||
|
}
|
||||||
heap_free(This);
|
heap_free(This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1159,7 +1163,6 @@ static HRESULT WINAPI ScriptControl_get_Language(IScriptControl *iface, BSTR *p)
|
||||||
static HRESULT WINAPI ScriptControl_put_Language(IScriptControl *iface, BSTR language)
|
static HRESULT WINAPI ScriptControl_put_Language(IScriptControl *iface, BSTR language)
|
||||||
{
|
{
|
||||||
ScriptControl *This = impl_from_IScriptControl(iface);
|
ScriptControl *This = impl_from_IScriptControl(iface);
|
||||||
ScriptModule **modules;
|
|
||||||
CLSID clsid;
|
CLSID clsid;
|
||||||
|
|
||||||
TRACE("(%p)->(%s)\n", This, debugstr_w(language));
|
TRACE("(%p)->(%s)\n", This, debugstr_w(language));
|
||||||
|
@ -1167,24 +1170,21 @@ static HRESULT WINAPI ScriptControl_put_Language(IScriptControl *iface, BSTR lan
|
||||||
if (language && FAILED(CLSIDFromProgID(language, &clsid)))
|
if (language && FAILED(CLSIDFromProgID(language, &clsid)))
|
||||||
return CTL_E_INVALIDPROPERTYVALUE;
|
return CTL_E_INVALIDPROPERTYVALUE;
|
||||||
|
|
||||||
/* Alloc new global module */
|
|
||||||
modules = heap_alloc_zero(sizeof(*modules));
|
|
||||||
if (!modules) return E_OUTOFMEMORY;
|
|
||||||
|
|
||||||
modules[0] = create_module();
|
|
||||||
if (!modules[0]) {
|
|
||||||
heap_free(modules);
|
|
||||||
return E_OUTOFMEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (This->host) {
|
if (This->host) {
|
||||||
release_script_engine(This->host);
|
release_script_engine(This->host);
|
||||||
This->host = NULL;
|
This->host = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
release_modules(This);
|
/* Alloc global module */
|
||||||
This->modules = modules;
|
This->modules = heap_alloc_zero(sizeof(*This->modules));
|
||||||
This->module_count = 1;
|
if (!This->modules) return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
This->modules[0] = create_module();
|
||||||
|
if (!This->modules[0]) {
|
||||||
|
heap_free(This->modules);
|
||||||
|
This->modules = NULL;
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
if (!language)
|
if (!language)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -1332,7 +1332,7 @@ static HRESULT WINAPI ScriptControl_get_Modules(IScriptControl *iface, IScriptMo
|
||||||
|
|
||||||
TRACE("(%p)->(%p)\n", This, p);
|
TRACE("(%p)->(%p)\n", This, p);
|
||||||
|
|
||||||
if (!This->module_count) return E_FAIL;
|
if (!This->host) return E_FAIL;
|
||||||
|
|
||||||
*p = &This->IScriptModuleCollection_iface;
|
*p = &This->IScriptModuleCollection_iface;
|
||||||
IScriptControl_AddRef(iface);
|
IScriptControl_AddRef(iface);
|
||||||
|
|
|
@ -2414,7 +2414,16 @@ static void test_IScriptControl_get_Modules(void)
|
||||||
ok(hr == S_OK, "IScriptModuleCollection_get_Count failed: 0x%08x.\n", hr);
|
ok(hr == S_OK, "IScriptModuleCollection_get_Count failed: 0x%08x.\n", hr);
|
||||||
ok(count == 1, "count is not 1, got %d.\n", count);
|
ok(count == 1, "count is not 1, got %d.\n", count);
|
||||||
|
|
||||||
|
hr = IScriptControl_put_Language(sc, NULL);
|
||||||
|
ok(hr == S_OK, "IScriptControl_put_Language failed: 0x%08x.\n", hr);
|
||||||
|
|
||||||
|
hr = IScriptModuleCollection_get_Count(mods, &count);
|
||||||
|
ok(hr == E_FAIL, "IScriptModuleCollection_get_Count returned: 0x%08x.\n", hr);
|
||||||
|
|
||||||
IScriptModuleCollection_Release(mods);
|
IScriptModuleCollection_Release(mods);
|
||||||
|
hr = IScriptControl_get_Modules(sc, &mods);
|
||||||
|
ok(hr == E_FAIL, "IScriptControl_get_Modules returned: 0x%08x.\n", hr);
|
||||||
|
|
||||||
IScriptControl_Release(sc);
|
IScriptControl_Release(sc);
|
||||||
|
|
||||||
/* custom script engine */
|
/* custom script engine */
|
||||||
|
|
Loading…
Reference in New Issue