Bit of a bug fix / bug prevention
This commit is contained in:
@ -93,6 +93,15 @@ namespace Dawn {
|
||||
const std::function<void()> &fn,
|
||||
IStateProperty &property
|
||||
) {
|
||||
if(property.owner == nullptr) {
|
||||
property.owner = this;
|
||||
} else {
|
||||
// TODO: This actually isn't needed, but because I need to teardown
|
||||
// all the listeners on StateProperty<> that belong to this StateOwner
|
||||
// I need to keep track of what events I've subbed to, consuming more
|
||||
// memory, and I don't know if I actually need to do this or not.
|
||||
assertTrue(property.owner == this);
|
||||
}
|
||||
property._effectListners.push_back(fn);
|
||||
return fn;
|
||||
}
|
||||
@ -111,7 +120,9 @@ namespace Dawn {
|
||||
) {
|
||||
auto itProp = props.begin();
|
||||
while(itProp != props.end()) {
|
||||
(*itProp)->_effectListners.push_back(fn);
|
||||
auto property = *itProp;
|
||||
if(property->owner == nullptr) { property->owner = this; } else { assertTrue(property->owner == this); }
|
||||
property->_effectListners.push_back(fn);
|
||||
++itProp;
|
||||
}
|
||||
return fn;
|
||||
@ -130,6 +141,7 @@ namespace Dawn {
|
||||
const std::function<std::function<void()>()> &fn,
|
||||
IStateProperty &property
|
||||
) {
|
||||
if(property.owner == nullptr) { property.owner = this; } else { assertTrue(property.owner == this); }
|
||||
property._effectListnersWithTeardown.push_back(fn);
|
||||
|
||||
return std::bind([&](
|
||||
|
@ -37,9 +37,11 @@ namespace Dawn {
|
||||
std::function<void()> unsub;
|
||||
StateEvent<A...> *event;
|
||||
};
|
||||
|
||||
|
||||
class IStateProperty {
|
||||
public:
|
||||
IStateOwner *owner = nullptr;
|
||||
|
||||
std::vector<std::function<void()>> _effectListners;
|
||||
std::vector<std::function<std::function<void()>()>> _effectListnersWithTeardown;
|
||||
std::vector<std::function<void()>> _effectTeardowns;
|
||||
|
@ -43,11 +43,6 @@ namespace Dawn {
|
||||
tile->ticTacToe->tile = i++;
|
||||
}
|
||||
}
|
||||
|
||||
evtUnsub = useEventLegacy([&]{
|
||||
std::cout << "Legacy Event Invoked " << age << std::endl;
|
||||
evtUnsub();
|
||||
}, this->eventSceneUpdate);
|
||||
}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
|
Reference in New Issue
Block a user