[C++-sig] Passing inherited classes back to C++
Roman Yakovenko
roman.yakovenko at gmail.com
Sun May 6 11:22:09 CEST 2007
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/
More information about the Cplusplus-sig
mailing list