Crash in Constructor when subclassing AsyncTask

Hello,

i am totally new to Panda3D and currently working through the Manual. Now there’s my first question regarding a crash when subclassing AsyncTask and performing ANY action in the subclassed constructor. Take a look at the following code:

Class definition:

class CameraMovementTask : public AsyncTask
{
private:
    ClockObject *m_Clock;

public:
    CameraMovementTask();

    // Overriden from AsyncTask
    virtual AsyncTask::DoneStatus do_task();
};

Class constructor:

CameraMovementTask::CameraMovementTask() : AsyncTask( "Camera Movement Task" )
{
    cout << "CameraMovementTask::ctor()" << endl;
}

Interesting part is, that a crash occurs on instantiating the class:

dtool/src/dtoolbase/deletedBufferChain.cxx:51: void* DeletedBufferChain::allocate(size_t, TypeHandle): Assertion `size <= _buffer_size' failed.

But only when there’s some code in the constructor… if i remove the cout line, everything works as expected. Any ideas what’s going on here?

Thanks,
Egon

Hi, welcome to the forums!

I’m not entirely sure, but I ran into this issue a while ago. I simply had to put something like this in the class declaration:

    ALLOC_DELETED_CHAIN(CameraMovementTask);

Hello,
thank you for your reply rdb - will try that as soon as i’m at home!
Yours,
Egon

Yes, this is one of Panda’s (poorly documented) C++ conventions.

Any class that defines ALLOC_DELETED_CHAIN overrides the new and delete operations. It is therefore necessary for all derived classes to also define ALLOC_DELETED_CHAIN.

David