Browse Source

Change Signal to disconnect bad receivers quicker

pull/8/head
Anton Tarasenko 3 years ago
parent
commit
8251cc2057
  1. 15
      sources/Events/Signal.uc

15
sources/Events/Signal.uc

@ -183,16 +183,27 @@ protected function Finalizer()
* Must be a properly allocated `AcediaObject`. * Must be a properly allocated `AcediaObject`.
* @return New `Slot` object that will be connected to the caller `Signal` if * @return New `Slot` object that will be connected to the caller `Signal` if
* provided `receiver` is correct. Guaranteed to have class * provided `receiver` is correct. Guaranteed to have class
* `relatedSlotClass`. * `relatedSlotClass`. Guaranteed to not be `none` if allocated `receiver`
* is provided.
*/ */
public final function Slot NewSlot(AcediaObject receiver) public final function Slot NewSlot(AcediaObject receiver)
{ {
local Slot newSlot; local Slot newSlot;
if (receiver == none) {
return none;
}
newSlot = Slot(_.memory.Allocate(relatedSlotClass)); newSlot = Slot(_.memory.Allocate(relatedSlotClass));
newSlot.Initialize(self, receiver); if (newSlot.Initialize(self, receiver))
{
AddSlot(newSlot, receiver); AddSlot(newSlot, receiver);
return newSlot; return newSlot;
} }
newSlot.FreeSelf();
if (!receiver.IsAllocated()) {
Disconnect(receiver);
}
return none;
}
/** /**
* Disconnects all of the `receiver`'s `Slot`s from the caller `Signal`. * Disconnects all of the `receiver`'s `Slot`s from the caller `Signal`.

Loading…
Cancel
Save