So just like the title says, adding a functional handle for a class method to an array causes some kind of issue with the GC. No errors are reported when compiling or executing the script, but closing the game will flood the console with various warnings and errors.
A sample script:
funcdef void FuncDef(int);
class script{
array<FuncDef@> listeners;
script(){
// GC errors >>
listeners.insertLast(@FuncDef(this.class_method));
// No Problems with local variables >>
FuncDef@ local = FuncDef(this.class_method);
// No problems with global functions >>
listeners.insertLast(global_function);
}
void class_method(int a) { puts(a + ""); }
}
void global_function(int a) { puts(a + ""); }
The errors all look like below, but instead ‘m9’ and ‘$func’ different built-in angelscript and game specific types are given. Also ref count ranges somewhere around -3 > 3.
WARN : There is an external reference to an object in module 'm9', preventing it from being deleted
ERROR: Object {4}. GC cannot destroy an object of type '$func' as it can't see all references. Current ref count is 1.