[PATCH v2 0/1] MR10373: vbscript: Allow Property Let to accept VT_DISPATCH arguments.
When assigning an object (VT_DISPATCH) to a property, Wine looks for Property Set. If only Property Let is defined, fall back to using it with the object's default value. This allows code that uses Property Let with object arguments (which extracts the default value) to work when Property Set is not defined. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53844 -- v2: vbscript: Pass VT_DISPATCH as-is to Property Let without extracting default value. https://gitlab.winehq.org/wine/wine/-/merge_requests/10373
From: Francis De Brabandere <francisdb@gmail.com> On Windows, Property Let receives the object (VT_DISPATCH) directly, not its default value. Fix invoke_vbdisp to skip default-value extraction in the Property Let/Set code path, and select the function based on the dispatch flags instead of the value type. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53844 --- dlls/vbscript/tests/lang.vbs | 27 +++++++++++++++++++++++++++ dlls/vbscript/vbdisp.c | 4 ++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index c364f12c00b..897ccef135f 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -2108,6 +2108,7 @@ Class TestPropParam Public oDict Public gotNothing Public m_obj + Public m_objType Public Property Set bar(obj) Set m_obj = obj @@ -2126,6 +2127,14 @@ Class TestPropParam Public Property Let ten(a,b,c,d,e,f,g,h,i,j) oDict = a & b & c & d & e & f & g & h & i & j End Property + Public Property Let objProp(aInput) + m_objType = getVT(aInput) + If IsObject(aInput) Then + Set m_obj = aInput + Else + m_obj = aInput + End If + End Property End Class Set x = new TestPropParam @@ -2141,6 +2150,24 @@ Set x.foo("123") = Nothing call ok(x.oDict = "123","x.oDict = " & x.oDict & " expected 123") call ok(x.gotNothing=True,"x.gotNothing = " & x.gotNothing & " expected true") +' Property Let receives VT_DISPATCH argument as-is (does not extract default value) +Set y = New EndTestClassWithProperty +y.x = 42 +x.objProp = y +call ok(x.m_objType = "VT_DISPATCH*", "Property Let aInput type: " & x.m_objType & " expected VT_DISPATCH*") +call ok(x.m_obj = 42, "Property Let with object argument failed, m_obj = " & x.m_obj) + +' Property Let receives object without default property as VT_DISPATCH +Set z = New EmptyClass +x.objProp = z +call ok(x.m_objType = "VT_DISPATCH*", "Property Let no-default aInput type: " & x.m_objType & " expected VT_DISPATCH*") + +' Set with only Property Let defined should fail (no fallback to Let) +On Error Resume Next +Set x.objProp = y +call ok(Err.Number = 438, "Set Property Let only: Err.Number = " & Err.Number & " expected 438") +On Error GoTo 0 + set x = new TestPropSyntax set x.prop = new TestPropSyntax set x.prop.prop = new TestPropSyntax diff --git a/dlls/vbscript/vbdisp.c b/dlls/vbscript/vbdisp.c index 0ede0cfd6ba..d9f0fbb856a 100644 --- a/dlls/vbscript/vbdisp.c +++ b/dlls/vbscript/vbdisp.c @@ -219,14 +219,14 @@ static HRESULT invoke_vbdisp(vbdisp_t *This, DISPID id, DWORD flags, BOOL extern dp.rgvarg = buf; } - hres = get_propput_arg(This->desc->ctx, params, flags, dp.rgvarg, &needs_release); + hres = get_propput_arg(This->desc->ctx, params, flags | DISPATCH_PROPERTYPUTREF, dp.rgvarg, &needs_release); if(FAILED(hres)) { if(dp.rgvarg != buf) free(dp.rgvarg); return hres; } - func = This->desc->funcs[id].entries[V_VT(dp.rgvarg) == VT_DISPATCH ? VBDISP_SET : VBDISP_LET]; + func = This->desc->funcs[id].entries[(flags & DISPATCH_PROPERTYPUTREF) ? VBDISP_SET : VBDISP_LET]; if(!func) { FIXME("no letter/setter\n"); if(dp.rgvarg != buf) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10373
On Thu Mar 19 14:33:53 2026 +0000, Francis De Brabandere wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/10373/diffs?diff_id=252281&start_sha=ee453c3c4d4bce1c6b3b6f0b4560d121ccbfa4a1#18a8771bf91222ebfc4599f53729c95217a5ab51_2130_2131) Did some more windows tests and added some cases. Is this better?
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10373#note_132812
This merge request was approved by Jacek Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10373
participants (3)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb) -
Jacek Caban (@jacek)