[C++-sig] Object lifetime issue

English, Mark Mark.English at rbccm.com
Mon Sep 3 11:55:40 CEST 2007


> -----Original Message-----
> From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org]On
> Behalf Of Matt Holmes
> Sent: 02 September 2007 00:08
> To: c++-sig at python.org
> Subject: [C++-sig] Object lifetime issue
> 
> 
> I am trying to expose one of the classes in my engine as an abstract 
> class that is used as the base for a series of Python classes.
> 
> <snip>
> 
> I am executing the follwing Python script, which should create an 
> instance of the QuitCommand object, pass it to the 
> InputManagers::registerCommand method, which will store that command 
> object and use it to execute the given command later (which is 
> implemented in Python). The issue is that when I call the execute() 
> method of my store InputCommand*, my program crashes. From what I can 
> tell it's because Python is destroying the object I created in the 
> Python script below to pass to registerCommand. I thought 
> with_custodian_and_ward<1, 3> (the custodian should be 'this', the 
> InputManader, and the ward should be the InputCommand 
> sub-class object) 
> would stop the Python GC from destroying it, but I guess I was wrong.
> 

Would any of the other return policies be of any use either directly or as example code ? For example "return_internal_reference" which inherits from "with_custodian_and_ward_postcall" ?

Also, sys.getrefcount() may help you if you haven't seen it already, and also various debug build options for the python interpreter.

MarkE
________________________________________

This E-Mail (including any attachments) may contain privileged or confidential information.  It is intended only for the addressee(s) indicated above.

The sender does not waive any of its rights, privileges or other protections respecting this information.  

Any distribution, copying or other use of this E-Mail or the information it contains, by other than an intended recipient, is not sanctioned and is prohibited.

If you received this E-Mail in error, please delete it and advise the sender (by return E-Mail or otherwise) immediately. 

This E-Mail (including any attachments) has been scanned for viruses. 

It is believed to be free of any virus or other defect that might affect any computer system into which it is received and opened. 

However, it is the responsibility of the recipient to ensure that it is virus free. 

The sender accepts no responsibility for any loss or damage arising in any way from its use.

E-Mail received by or sent from RBC Capital Markets is subject to review by Supervisory personnel. 

Such communications are retained and may be produced to regulatory authorities or others with legal rights to the information.

IRS CIRCULAR 230 NOTICE:  TO COMPLY WITH U.S. TREASURY REGULATIONS, WE ADVISE YOU THAT ANY U.S. FEDERAL TAX ADVISE INCLUDED IN THIS COMMUNICATION IS NOT INTENDED OR WRITTEN TO BE USED, AND CANNOT BE USED, TO AVOID ANY U.S. FEDERAL TAX PENALTIES OR TO PROMOTE, MARKET, OR RECOMMEND TO ANOTHER PARTY ANY TRANSACTION OR MATTER.



More information about the Cplusplus-sig mailing list