Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Problem with deleting the engine and context.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Rain Dog   Members   -  Reputation: 136

Like
0Likes
Like

Posted 25 October 2004 - 10:42 AM

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:
	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();



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3057

Like
0Likes
Like

Posted 25 October 2004 - 10:56 AM

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.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 Rain Dog   Members   -  Reputation: 136

Like
0Likes
Like

Posted 25 October 2004 - 11:05 AM

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.

#4 Rain Dog   Members   -  Reputation: 136

Like
0Likes
Like

Posted 25 October 2004 - 11:29 AM

Fixed it. Was with a global CString object that i used to report my errors. Instead i encapsulated it within a COutStream class. Works really well now.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS