[C++-sig] runtime error R6025 - pure virtual function call

Maximilian Wilson wilson.max at gmail.com
Fri Jan 26 02:36:30 CET 2007


On 1/25/07, Dave Wolfe <dwolfe at gforcetech.com> wrote:
> > I'm no expert on bpl, but are you sure this isn't a dangling pointer?
> > The bpl::object myPyPrinter goes out of scope when you exit the try
> > block, which presumably destroys whatever ICallable retval is pointing
> > to...
>
> Thanks for the suggestion.  Since I'm fuzzy as to how memory management
> works in bpl, I'd better be more careful about this in general.

I know that Python expects C-side programmers to manage reference
counts, and bpl::objects exist in part to take care of reference
counting, in the same way as a shared_ptr<>. (Actually, I think it's
the bpl::handle<> inside of a bpl::object that actually handles
refcounts.) A Python function which returns a newly-created object
won't have any references to it except the one it returns, which gets
encapsulated in your bpl::object; once the bpl::object goes out of
scope PYTHON_DECREF will be called, which presumably frees the object
immediately.

HTH, and maybe an expert will reply...

-Max Wilson

-- 
Be pretty if you are, be witty if you can,
But be cheerful if it kills you.

Everything in Windows is very simple, but the simplest thing is difficult.
    -Clausewitz



More information about the Cplusplus-sig mailing list