[PATCH 2/2] vbscript: Use the global script dispatch for items with the SCRIPTITEM_GLOBALMEMBERS flag.

Gabriel Ivăncescu gabrielopcode at gmail.com
Tue Feb 25 06:48:48 CST 2020


On 25/02/2020 13:58, Jacek Caban wrote:
> On 24.02.2020 14:44, Gabriel Ivăncescu wrote:
>> Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
>> ---
>>   dlls/vbscript/tests/vbscript.c |  3 +++
>>   dlls/vbscript/vbscript.c       | 14 ++++++++++++--
>>   2 files changed, 15 insertions(+), 2 deletions(-)
>>
>> diff --git a/dlls/vbscript/tests/vbscript.c 
>> b/dlls/vbscript/tests/vbscript.c
>> index 8536ee1..9c62678 100644
>> --- a/dlls/vbscript/tests/vbscript.c
>> +++ b/dlls/vbscript/tests/vbscript.c
>> @@ -1813,6 +1813,9 @@ static void test_named_items(void)
>>       ok(hres == E_INVALIDARG, "GetScriptDispatch returned: %08x\n", 
>> hres);
>>       script_disp = get_script_dispatch(script, NULL);
>> +    script_disp2 = get_script_dispatch(script, L"globalItem");
>> +    ok(script_disp == script_disp2, "get_script_dispatch returned 
>> different dispatch objects.\n");
>> +    IDispatchEx_Release(script_disp2);
>>       script_disp2 = get_script_dispatch(script, L"codeONLYitem");
>>       ok(script_disp != script_disp2, "get_script_dispatch returned 
>> same dispatch objects.\n");
>> diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c
>> index 27985bf..c563a09 100644
>> --- a/dlls/vbscript/vbscript.c
>> +++ b/dlls/vbscript/vbscript.c
>> @@ -91,6 +91,16 @@ static inline BOOL is_started(VBScript *This)
>>           || This->state == SCRIPTSTATE_DISCONNECTED;
>>   }
>> +static HRESULT create_named_item_script_obj(script_ctx_t *ctx, 
>> named_item_t *item)
>> +{
>> +    if(item->flags & SCRIPTITEM_GLOBALMEMBERS) {
>> +        item->script_obj = ctx->script_obj;
>> +        IDispatchEx_AddRef(&item->script_obj->IDispatchEx_iface);
>>
> 
> ctx->script_obj may not be right anymore at this point, see the attached 
> test. It would be probably better to do that in AddNamedItem(). We 
> already have SCRIPTITEM_GLOBALMEMBERS special treatment there.
> 
> 

Right, I'll have to see what happens when it is restarted and try to add 
a test if it's not too hackish.

Thanks,
Gabriel



More information about the wine-devel mailing list