Jump to content

[SOLVED] Async with runv


photo

Recommended Posts

Hi,

 

I have some trouble with the Async class, I need to pass a parameter who is an array (Asset assets[0] where asset is an script object).

When I call the runv I have an error Async::run(): unknown type of argument (string), I am not sure if the trouble is because I try to pass an array of internal object, but the error message is about the name of the function theorically and the function exist.

 

My call is :

 

ModulImportThread::asynchronous = new Async();

ModulImportThread::asynchronous.runv("Environment::loadAssetOthersFromSts", ModulImportThread::asset_list);

Do you have any suggestion how I can do that ?? and may be will be nice to have runv function with other variable and keep the last parameter for the array.

Tony

Link to comment
  • 2 weeks later...

Hi Anthony!

 

Looks like it's a bug, thank you for this. If you look inside engine code you can notice that when you pass function as a string it'll try to search it by passing size of your array which is incorrect.

int Async::run(const Variable &name,const Vector<Variable> &arguments) {
        ...
	if(name.getType() == Variable::STRING) {
		const char *function_name = name.getString();
		if(interpreter->is_extern_function(function_name)) {
			ExternFunctionBase *extern_function = interpreter->getExternFunction(function_name,arguments.size());
        ...
        }
}

So try to get function id in UnigineScript first and then call Async::callv(id,your_array).

Link to comment
×
×
  • Create New...