Python/XPCOM/C++ question.

Mark Hammond mhammond at skippinet.com.au
Thu Mar 6 22:58:49 EST 2003


Denis Suhanov wrote:
> Hello guys,
> 
> I am working on a project that uses mozilla's XPCOM to connect different
> components. Some of them are written in C++  and some in (lovely) Python.

Note there is a pyxpcom mailing list - 
http://listserv.ActiveState.com/mailman/listinfo/pyxpcom

> now when I was trying to  call the function, I realized that although every
> time I was getting a valid array of pointers to nsISupport interface (I
> could see that vtbl points to something like PythonXPCOM_Stub in debugger),
> an attempt to call any nsIEntry's function on one of these pointer would
> cause my program to crash. I've spent some time trying to investigate it
> (and after spending several hours on that, I even stared annoying folks at
> netscape.public.mozilla.xpcom conference with that question) and eventually
> found out that if (in my C++ program that calls this Python method) I
> explicitly call QueryInterface on the pointers returned in the array,
> everything would work just fine (of course, that's introduced an additional
> ::Release call)
> 
> Now isn't that a bit surprising? I mean, the interface clearly states "we
> are going to work with the interfaces to nsIEntry", then the C++ program
> that calls the method prepared an array of typed pointers to nsIEntry
> interface and finally PytXPCOM (unless I am missing something) is informed
> about the type of interfaces expected (through *.xpt). I perfectly
> understand that there should be a good reason for such a behavior, so the
> only thing that I am trying to find out is what that reason is.

Yes, this is a bug in pyxpcom.  Specifically, it seems that we ignore 
the IID for arrays.  The function FillSingleArray in VariantUtils.cpp 
isn't passed the IID, and it should be.  I haven't the time right now to 
look further into it, but feel free to create a bug in bugzilla and 
assign it to me.

Mark.





More information about the Python-list mailing list