nunuhara/xsystem4

system.GlobalLoad() should not call destructors

Closed this issue · 0 comments

test.jaf:

struct Foo {
	Foo() {
		system.Output("Foo::Foo()\n");
	}
	~Foo() {
		system.Output("Foo::~Foo()\n");
	}
};
Foo globalFoo;

int main(void)
{
	system.Output("GlobalSave()\n");
	system.GlobalSave("foo", "foo.asd");
	system.Output("GlobalLoad()\n");
	system.GlobalLoad("foo", "foo.asd");
	system.Output("GlobalLoad() again\n");
	system.GlobalLoad("foo", "foo.asd");
	system.Output("Exit()\n");
	system.Exit(0);
	return 0;
}

System40.exe output:

Foo::Foo()
GlobalSave()
GlobalLoad()
GlobalLoad() again
Exit()
Foo::~Foo()

xsystem4 output:

Foo::Foo()
GlobalSave()
GlobalLoad()
Foo::~Foo()
GlobalLoad() again
Foo::~Foo()
Exit()

In System40.exe GlobalLoad() does not trigger destructors of old struct objects (but System.Exit() does).
This leads to an issue in Daibanchou that StructBacklog loses its Bitarray handle when a saved file is loaded.