What steps will reproduce the problem?
1. Create a TDelphiWebScript
2. Create an external unit, and assign its Script property to the scripter
object from step 1.
3. Call Free on the scripter object without freeing the external unit first.
What is the expected output? What do you see instead?
Expected: Everything should clean up properly.
Observed: Memory error when the compiler cleans up its Units list in the
destructor.
Here's what's going on:
Scripter component gets destroyed.
TComponent.Destroy calls RemoveFreeNotifications.
RemoveFreeNotifications calls Notification(self, opRemove) on the unit object.
This invokes:
procedure TdwsAbstractUnit.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (AComponent = FScript) then
FScript := nil;
end;
FScript is set to nil, but because the field is changed directly, the following
line in TdwsAbstractUnit.SetScript was not called:
FScript.RemoveUnit(Self);
This leaves an interface reference to the unit object sitting around in the
compiler's unit list, while the object is destroyed out from under it.
To fix this, TdwsAbstractUnit.Notification should instead say "self.Script :=
nil;".
Original issue reported on code.google.com by masonwhe...@gmail.com on 8 May 2013 at 11:11
Original issue reported on code.google.com by
masonwhe...@gmail.com
on 8 May 2013 at 11:11