Hi! It's me again :-)
I have another question about handles. I have to make sure about a few things, our AS scripts will be written by people not very familiar with AngelScript, and I have to make everything safe for them :-)
Here's a AS code snippet:
WindLevel wl(1.1, 4.5);
WindArea wa();
wa.AddWindLevel(@wl);
WindLevel@ wl2;
@wl2 = @wa.GetWindLevel(0);
WindLevel class has ctor/dtor and addref/release behaviours registered. WindArea::GetWindLevel calls AddRef upon succesful lookup. This works as expected.
However, when I change the code to this:
WindLevel wl(1.1, 4.5);
WindArea wa();
wa.AddWindLevel(@wl);
WindLevel wl2(1.0, 1.0); // no default ctor, we must call non-default ctor for proper addref count
wl2 = wa.GetWindLevel(0);
The problem here is easily overlooked. WindLevel
doesn't have the assignment behaviour registered and the last assignment simply does a shallow copy,
including the refcount variable. My guess is that I have to register the assignment behaviour that doesn't copy the refcount variable. Is there anything else I should be aware of?