Hi Richard, Ashley and all,<br><br>I got a similar scenario in QT4 tutorial:<br>#######################<br><pre>    MyWidget::MyWidget(QWidget *parent)<br>        : QWidget(parent)<br>    {<br>        setFixedSize(200, 120);
<br><br>        QPushButton *quit = new QPushButton("Quit", this);<br>        quit->setGeometry(62, 40, 75, 30);<br>        quit->setFont(QFont("Times", 18, QFont::Bold));<br><br>        connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
<br>    }<br></pre>
#######################<br><br>'quit' is a heap variable but will be implicitly deleted by parent widget.<br>If one does so in scripting language, for instance in perl, the refcounting <br>mechanism will destroy 'quit' since it is out of scope once returning from new.
<br><br>A possible solution for this case: once called with an explicit parent widget, I <br>can increase the refcount of 'quit' to 2. Thus even the stash is out of scope, the <br>underlying cpp instance will not be deleted.
<br><br>This is the case adding stuff into another, while the reverse mentioned in boost <br>document is more complex. It is very hard to determine, say 'Bar *Foo(...) ', the <br>returned object is a part of other or a new heap variable. I got such situation 
<br>during porting TagLib to Perl. I have to:<br>1). got a part of other / an object reference: allocate a new heap copy. this <br>        solution has not only performance disadvantage, but also it cannot 'export' <br>        such internal struct of an object to edit;
<br>     another possible solution is making the stash behave much more like a QT <br>        guard pointer;<br>2). got a heap object: do as usual;<br><br>The prerequisite is I know what kind of stuff will be returned exactly. 
<br>It will be nice one can get such information from output of smoke.<br>Any idea?<br><br>Cheers, Dongxu<br>__END__<br><a href="http://search.cpan.org/~dongxu">http://search.cpan.org/~dongxu</a>