Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 31 ++++++++++++++++-------------- dlls/msscript.ocx/tests/msscript.c | 20 +++++++++++++++++++ 2 files changed, 37 insertions(+), 14 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index 112403a..ee0cf25 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -355,8 +355,6 @@ static void uncache_module_objects(ScriptModule *module) ITypeComp_Release(module->script_typecomp); module->script_typecomp = NULL; } - if (module->procedures) - module->procedures->count = -1; }
static HRESULT set_script_state(ScriptHost *host, SCRIPTSTATE state) @@ -369,12 +367,15 @@ static HRESULT set_script_state(ScriptHost *host, SCRIPTSTATE state) return hr; }
-static HRESULT start_script(ScriptHost *host) +static HRESULT start_script(ScriptModule *module) { HRESULT hr = S_OK;
- if (host->script_state != SCRIPTSTATE_STARTED) - hr = set_script_state(host, SCRIPTSTATE_STARTED); + if (module->host->script_state != SCRIPTSTATE_STARTED) + { + hr = set_script_state(module->host, SCRIPTSTATE_STARTED); + if (SUCCEEDED(hr)) uncache_module_objects(module); + }
return hr; } @@ -418,10 +419,12 @@ static HRESULT parse_script_text(ScriptModule *module, BSTR script_text, DWORD f EXCEPINFO excepinfo; HRESULT hr;
- hr = start_script(module->host); + hr = start_script(module); if (FAILED(hr)) return hr;
uncache_module_objects(module); + if (module->procedures) + module->procedures->count = -1;
hr = IActiveScriptParse_ParseScriptText(module->host->parse, script_text, module->name, NULL, NULL, 0, 1, flag, res, &excepinfo); @@ -438,7 +441,7 @@ static HRESULT run_procedure(ScriptModule *module, BSTR procedure_name, SAFEARRA HRESULT hr; UINT i;
- hr = start_script(module->host); + hr = start_script(module); if (FAILED(hr)) return hr;
hr = get_script_dispatch(module, &disp); @@ -1082,7 +1085,7 @@ static HRESULT WINAPI procedure_enum_Next(IEnumVARIANT *iface, ULONG celt, VARIA if (!rgVar) return E_POINTER; if (!This->procedures->module->host) return E_FAIL;
- hr = start_script(This->procedures->module->host); + hr = start_script(This->procedures->module); if (FAILED(hr)) return hr;
hr = get_script_typeinfo(This->procedures->module, &ti); @@ -1295,7 +1298,7 @@ static HRESULT WINAPI ScriptProcedureCollection_get__NewEnum(IScriptProcedureCol if (!ppenumProcedures) return E_POINTER; if (!This->module->host) return E_FAIL;
- hr = start_script(This->module->host); + hr = start_script(This->module); if (FAILED(hr)) return hr;
hr = get_script_typeinfo(This->module, &ti); @@ -1334,7 +1337,7 @@ static HRESULT WINAPI ScriptProcedureCollection_get_Item(IScriptProcedureCollect if (!ppdispProcedure) return E_POINTER; if (!This->module->host) return E_FAIL;
- hr = start_script(This->module->host); + hr = start_script(This->module); if (FAILED(hr)) return hr;
hr = get_script_typeinfo(This->module, &typeinfo); @@ -1414,11 +1417,11 @@ static HRESULT WINAPI ScriptProcedureCollection_get_Count(IScriptProcedureCollec if (!plCount) return E_POINTER; if (!This->module->host) return E_FAIL;
- hr = start_script(This->module->host); - if (FAILED(hr)) return hr; - if (This->count == -1) { + hr = start_script(This->module); + if (FAILED(hr)) return hr; + hr = get_script_typeinfo(This->module, &ti); if (FAILED(hr)) return hr;
@@ -1609,7 +1612,7 @@ static HRESULT WINAPI ScriptModule_get_CodeObject(IScriptModule *iface, IDispatc
if (!This->host) return E_FAIL;
- hr = start_script(This->host); + hr = start_script(This); if (FAILED(hr)) return hr;
hr = get_script_dispatch(This, ppdispObject); diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c index 5b95863..2e7f14d 100644 --- a/dlls/msscript.ocx/tests/msscript.c +++ b/dlls/msscript.ocx/tests/msscript.c @@ -3855,7 +3855,19 @@ static void test_IScriptControl_get_Procedures(void) CHECK_CALLED(GetTypeAttr); CHECK_CALLED(ReleaseTypeAttr);
+ /* Reset uncaches the objects, but not the count */ + SET_EXPECT(SetScriptState_INITIALIZED); + IScriptControl_Reset(sc); + CHECK_CALLED(SetScriptState_INITIALIZED); + count = 0; + hr = IScriptProcedureCollection_get_Count(procs, &count); + ok(hr == S_OK, "IScriptProcedureCollection_get_Count failed: 0x%08x.\n", hr); + ok(count == ARRAY_SIZE(custom_engine_funcs), "count is not %u, got %d.\n", TypeInfo_GetTypeAttr_cFuncs, count); + /* Try without ITypeComp interface */ + SET_EXPECT(SetScriptState_STARTED); + SET_EXPECT(GetScriptDispatch); + SET_EXPECT(GetTypeInfo); SET_EXPECT(QI_ITypeComp); V_VT(&var) = VT_BSTR; V_BSTR(&var) = SysAllocString(L"foobar"); @@ -3863,8 +3875,16 @@ static void test_IScriptControl_get_Procedures(void) ok(hr == E_NOINTERFACE, "IScriptProcedureCollection_get_Item returned: 0x%08x.\n", hr); ok(V_VT(&var) == VT_BSTR, "var type not BSTR, got %d.\n", V_VT(&var)); VariantClear(&var); + CHECK_CALLED(SetScriptState_STARTED); + CHECK_CALLED(GetScriptDispatch); + CHECK_CALLED(GetTypeInfo); CHECK_CALLED(QI_ITypeComp);
+ count = 0; + hr = IScriptProcedureCollection_get_Count(procs, &count); + ok(hr == S_OK, "IScriptProcedureCollection_get_Count failed: 0x%08x.\n", hr); + ok(count == ARRAY_SIZE(custom_engine_funcs), "count is not %u, got %d.\n", TypeInfo_GetTypeAttr_cFuncs, count); + /* Make ITypeComp available */ TypeComp_available = TRUE; SET_EXPECT(QI_ITypeComp);