[PyQt] How to write handwritten code to access the C++ object when the corresponding python object destroyed?

Phil Thompson phil at riverbankcomputing.com
Thu Feb 20 12:59:16 GMT 2020


Read the %MethodCode documentation.

On 20/02/2020 12:49, Weitian Leung wrote:
> Did you mean the wrapped class destructor? It's not the case I want...
> 
> struct IDemo
>> {
>>     virtual void do_sth(BSTR bstr) = 0;
>> };
>> 
> 
> The IDemo is created by other C++ interface, the correct way to pass 
> the
> bstr to *do_sth *is call *SysAllocString*,
> and after the call returned, we need call *SysFreeString* to free the 
> bstr.
> Because the IDemo instance will not take over the ownership of the 
> bstr.
> 
> So when mapped the BSTR to str, it seems that we don't have any chance 
> to
> call the *SysFreeString *to free the str that allocated inside
> *%ConvertToTypeCode.*
> 
> 
> 
> On Thu, Feb 20, 2020 at 5:07 PM Phil Thompson 
> <phil at riverbankcomputing.com>
> wrote:
> 
>> I meant the C++ destructor, not __dtor__.
>> 
>> Phil
>> 



More information about the PyQt mailing list