Re: GtkImageView




On Jan 6, 2008, at 1:59 PM, Jeffrey Ratcliffe wrote:

On 05/01/2008, Emmanuele Bassi <ebassi gmail com> wrote:
try with:

 GdkRectangle_copy *

instead of GtkRectangle_ornull *.

That works, thanks for the help.

Why didn't it work before?

Memory lifetime.

The object returned to perl was pointing at the spot on the C stack where the rect lived. After the xsub returned, this no longer contained a rectangle, and just gave you randomly-changing garbage. I didn't crash because you didn't try to write to it, and the address was still inside the valid address space of the process.

The _copy typemap variant instead creates a copy of the object, so the reference returned to perl points to its own heap copy of the rectangle.

If you're morbidly curious, see the "Wrapping Boxed Types" section of the Binding HowTo:
http://gtk2-perl.sourceforge.net/doc/binding_howto.pod.html#wrapping%20boxed%20types


--
zella (crying):  I want...
us:  What?
zella (still crying):  I want...  something!





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]