Dear Thomas,
I think I finally catched the bug. In the bdx_com.c file in the
BDXScalar2Variant function the BDX_HANDLE case was handled in the
following way:
case BDX_HANDLE:
{
LPSTREAM lStream = pBDXData->data.raw_data[0].ptr;
void* lTmpPtr = (void*) V_DISPATCH(pVariantData);
HRESULT lRc = CoUnmarshalInterface(lStream,&IID_IDispatch,
&lTmpPtr);
// the problem is here ^
// lTmpPtr first receives the value of V_DISPATCH(pvariantData),
// which is NULL, then this is overwritten with the required ptr,
// however V_DISPATCH(pvariantData) remains untouched,
if(FAILED(lRc)) {
BDX_ERR(printf("unmarshalling stream ptr %08x failed with hr=%08x\n",
lStream,lRc));
return -1;
} else {
BDX_ERR(printf("successfully marshalled COM interface\n"));
// to see that this is really the problem change this line to
// BDX_ERR(printf("successfully marshalled COM interface (%p %p)\n",
// lTmpPtr,V_DISPATCH(pvariantData)));
}
/* create SEXP for COM object */
V_VT(pVariantData) = VT_DISPATCH;
break;
}
A simple soultion is not to use a temporary pointer like below
case BDX_HANDLE:
{
LPSTREAM lStream = pBDXData->data.raw_data[0].ptr;
//void* lTmpPtr;
HRESULT lRc = CoUnmarshalInterface(lStream,&IID_IDispatch,
(void *) &V_DISPATCH(pVariantData));
if(FAILED(lRc)) {
BDX_ERR(printf("unmarshalling stream ptr %08x failed with hr=%08x\n",
lStream,lRc));
return -1;
} else {
// Or copy the received value to the variant data structure like the
// commented line here
// V_DISPATCH(pVariantData)=lTmpPtr ;
BDX_ERR(printf("successfully marshalled COM interface (%p) \n",
//lTmpPtr,
V_DISPATCH(pVariantData)));
}
/* create SEXP for COM object */
V_VT(pVariantData) = VT_DISPATCH;
break;
}
With either modification the reported problems disappear.
Best wishes
Vilmos
--
Vilmos Prokaj
Eötvös Loránd University,
Department of Probability and Statistics
Pázmány Péter sétány 1/C
Budapest, 1117
Hungary
e-mail:[EMAIL PROTECTED]
_______________________________________________
Rcom-l mailing list
Rcom-l@mailman.csd.univie.ac.at
http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l
More information (including a Wiki) at http://rcom.univie.ac.at