Jump to content
  • Advertisement
Sign in to follow this  
FDsagizi

Pod type and Null pointer exception - bug with call destructor

This topic is 2231 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
I haven't been able to reproduce this problem. I wrote the following test:


{
COutStream out;
asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
engine->SetMessageCallback(asMETHOD(COutStream, Callback), &out, asCALL_THISCALL);
engine->RegisterObjectType("TestLink", sizeof(CObject), asOBJ_VALUE | asOBJ_APP_CLASS_CD);
engine->RegisterObjectBehaviour("TestLink", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(Construct), asCALL_CDECL_OBJLAST);
engine->RegisterObjectBehaviour("TestLink", asBEHAVE_CONSTRUCT, "void f(const TestLink &in)", asFUNCTION(CopyConstruct), asCALL_CDECL_OBJLAST);
engine->RegisterObjectBehaviour("TestLink", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(Destruct), asCALL_CDECL_OBJLAST);
asIScriptModule *mod = engine->GetModule("mod", asGM_ALWAYS_CREATE);
mod->AddScriptSection("test",
"class Object3 \n"
"{ \n"
" Object3( TestLink str ) \n"
" { \n"
" Object3 @null_object = null; \n"
" null_object.Do(); \n"
" } \n"
" void Do() {} \n"
"} \n"
"void Main() \n"
"{ \n"
" Object3 @oo = Object3( TestLink() ); \n"
"} \n");
r = mod->Build();
if( r < 0 )
TEST_FAILED;
CObject_constructCount = 0;
CObject_destructCount = 0;
asIScriptContext *ctx = engine->CreateContext();
r = ExecuteString(engine, "Main()", mod, ctx);
if( r != asEXECUTION_EXCEPTION )
TEST_FAILED;
if( CObject_constructCount != 2 ||
CObject_destructCount != 1 )
TEST_FAILED;
ctx->Release();
if( CObject_constructCount != 2 ||
CObject_destructCount != 2 )
TEST_FAILED;
engine->Release();
}

Share this post


Link to post
Share on other sites
FDsagizi, when you say "Pod type", do you mean that the type is registered with asOBJ_CLASS_POD? POD types aren't allowed to have user-defined destructors.

http://en.wikipedia.org/wiki/Plain_old_data_structure

Not sure if that's relevant, but it might be confusing the compiler.

Share this post


Link to post
Share on other sites
Thanks a lot. I've fixed the problem in revision 1430.

It was a flag 'dontCleanupOnException' that I had forgotten to serialize with the saved bytecode.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!