[C++-sig] Passing inherited classes back to C++

Tom Brooks tgbrooks at gmail.com
Sun May 6 11:37:34 CEST 2007


Wow, that was a great guess! I kept a reference to the quad in Python, and
it all went fine. The FAQ has a part about just this situation, so I think
I'm all set now. Thanks a bunch for the help!

BTW, for future reference, what else would you have wanted to see?

On 5/6/07, Roman Yakovenko <roman.yakovenko at gmail.com> wrote:
>
> On 5/6/07, Tom Brooks <tgbrooks at gmail.com> wrote:
> > I run this python code:
> >
> > quad = Renderer.Quad(250, 250, 64,64)
> > c = Renderer.Color()
> > Renderer.AddRenderable(quad) #Removing this line makes it not crash
> >
> > AddRenderable does:
> > renderables.push_back(renderable);
> >
> > And later that frame, this is done:
> >     for(std::list<Renderable*>::iterator itr =
> > renderables.begin(); itr != renderables.end(); itr++)
> >     {
> >         Renderable* renderable = *itr;
> >         renderable->Draw(); //It crashes here! With error "R6025: pure
> > virtual function call".
> >     }
> >
> > I use your Py++ code (only thing changed is it's namespace, which is now
> > Renderer), along with:
> >
> >     def("AddRenderable",&AddRenderable);
> >
> > in the Renderer namespace.
> >
> > My C++ code runs just fine if I don't use anything from Python.
> >
> > There, I think that's complete.
>
> This is not a complete example, but it allows to make a guess - memory
> management.
> To prove this, try to hold a reference to "quad" variable somewhere in
> Python and run the code.
>
> --
> Roman Yakovenko
> C++ Python language binding
> http://www.language-binding.net/
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070506/2847fda0/attachment.htm>


More information about the Cplusplus-sig mailing list