int result;
asIScriptEngine* ASEngine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
asIScriptContext* ASCtx;
//RegisterEngineObjects(ASEngine);
ASEngine->AddScriptSection(0, "section", Script, (int)strlen(Script), 0);
COutStream out;
ASEngine->Build(0, &out);
if(Errors.GetLength() > 0)
{
MessageBox(0, (LPCTSTR)Errors, 0,0 );
Errors = "";
return;
}
result = ASEngine->CreateContext(&ASCtx);
result = ASCtx->Prepare(ASEngine->GetFunctionIDByDecl(0, "void main()"));
result = ASCtx->Execute();
result = ASCtx->Release();
result = ASEngine->Release();
Problem with deleting the engine and context.
My program keeps crashing after i instantiate an engine or context object when i go to close my program. i get an unhandled exception.
If i omit all of my AS code, the program terminates fine.
this is my code:
What is Errors.GetLength()? I assume it holds the compiler messages from the Build() call. You really ought to verify the return message from the Build() call instead.
I can't see any obvious errors with your code. You'll need to verify the return codes for each of the calls. AngelScript returns a negative value on error (the exact meaning of the value can be seen in angelscript.h).
Also make sure the ctx is not null when calling Release() on it.
I can't see any obvious errors with your code. You'll need to verify the return codes for each of the calls. AngelScript returns a negative value on error (the exact meaning of the value can be seen in angelscript.h).
Also make sure the ctx is not null when calling Release() on it.
The script builds fine, no errors are generated during the building of the script or during the registration of the script.
Nor are any errors reported when releasing the context or the engine.
After any script runs, even a
void main()
{
return;
}
will generate the error.
The error does not surface at anytime during the execution of the script, nor does it occur in the code block where i instantiate and execute my script.
It surfaces when i exit my program and the program attempts MFC standard cleanup code. im going to try WIP4 to see if it is a WIP5 specific problem.
Nor are any errors reported when releasing the context or the engine.
After any script runs, even a
void main()
{
return;
}
will generate the error.
The error does not surface at anytime during the execution of the script, nor does it occur in the code block where i instantiate and execute my script.
It surfaces when i exit my program and the program attempts MFC standard cleanup code. im going to try WIP4 to see if it is a WIP5 specific problem.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement