View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0038151 | FPC | RTL | public | 2020-11-29 23:52 | 2020-12-06 11:51 |
Reporter | serbod | Assigned To | Sven Barth | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | Windows | ||||
Product Version | 3.3.1 | ||||
Fixed in Version | 3.3.1 | ||||
Summary | 0038151: ComObj property set by reference | ||||
Description | Property assignment for ComObj variant in some case need special treatment (as in remarks from https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-idispatch-invoke). Included path fixing assignment of another COM object to property of COM object, as in example. | ||||
Steps To Reproduce | // At least two SAPI voices must be installed! // Win7+ have 2 English voices by default uses ComObj; procedure TestVoice(); var SpVoice, SpVoicesList: Variant; begin SpVoice := CreateOleObject('SAPI.SpVoice'); SpVoicesList := SpVoice.GetVoices(); // assign second speech voice as default voice, cause 'Member not found' error SpVoice.Voice := SpVoicesList.Item(1); SpVoice.Speak('Hello, world!'); end; | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 47687 | ||||
FPCOldBugId | |||||
FPCTarget | - | ||||
Attached Files |
|
|
comobj.pp.diff (1,546 bytes)
*** C:/fpcupdeluxe/fpcsrc/packages/winunits-base/src/comobj.pp Fri Nov 27 16:50:41 2020 --- C:/Work/ZhdunQMS/src/comobj.pp Mon Nov 30 01:45:06 2020 *************** *** 1381,1392 **** case InvokeKind of DISPATCH_PROPERTYPUT: begin ! if (Arguments[0].VType and varTypeMask) = varDispatch then InvokeKind:=DISPATCH_PROPERTYPUTREF; { first name is actually the name of the property to set } DispIDs^[0]:=DISPID_PROPERTYPUT; DispParams.rgdispidNamedArgs:=@DispIDs^[0]; ! inc(DispParams.cNamedArgs); end; DISPATCH_METHOD: { It appears that certain COM servers expect both DISPATCH_METHOD and DISPATCH_PROPERTYGET --- 1381,1393 ---- case InvokeKind of DISPATCH_PROPERTYPUT: begin ! if ((Arguments[0].VType and varTypeMask) in [varDispatch, varVariant]) ! and ((Arguments[0].VType and varByRef) <> 0) then InvokeKind:=DISPATCH_PROPERTYPUTREF; { first name is actually the name of the property to set } DispIDs^[0]:=DISPID_PROPERTYPUT; DispParams.rgdispidNamedArgs:=@DispIDs^[0]; ! DispParams.cNamedArgs:=1; end; DISPATCH_METHOD: { It appears that certain COM servers expect both DISPATCH_METHOD and DISPATCH_PROPERTYGET comobj.pp.patch (366 bytes)
1384c1384,1385 < if (Arguments[0].VType and varTypeMask) = varDispatch then --- > if ((Arguments[0].VType and varTypeMask) in [varDispatch, varVariant]) > and ((Arguments[0].VType and varByRef) <> 0) then 1389c1390 < inc(DispParams.cNamedArgs); --- > DispParams.cNamedArgs:=1; |
|
I wrote an article about that in UNDU in 1999. It may be that the interface is broken, but even then there where at least two voices. (Although I used the Parrot) Will see if I can dig up that code again. It should not fail, but right now I am on Linux. |
|
I've fixed it slightly differently, cause not every Variant passed in should also be passed as reference (at least Delphi does not do so). Please test and close if okay. |
|
It works, thanks! |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-11-29 23:52 | serbod | New Issue | |
2020-11-29 23:52 | serbod | File Added: comobj.pp.diff | |
2020-11-29 23:52 | serbod | File Added: comobj.pp.patch | |
2020-12-02 21:53 | Thaddy de Koning | Note Added: 0127325 | |
2020-12-04 23:09 | Sven Barth | Assigned To | => Sven Barth |
2020-12-04 23:09 | Sven Barth | Status | new => resolved |
2020-12-04 23:09 | Sven Barth | Resolution | open => fixed |
2020-12-04 23:09 | Sven Barth | Fixed in Version | => 3.3.1 |
2020-12-04 23:09 | Sven Barth | Fixed in Revision | => 47687 |
2020-12-04 23:09 | Sven Barth | FPCTarget | => - |
2020-12-04 23:09 | Sven Barth | Note Added: 0127348 | |
2020-12-06 11:51 | serbod | Status | resolved => closed |
2020-12-06 11:51 | serbod | Note Added: 0127371 |