Bit of a bug fix / bug prevention
This commit is contained in:
@ -93,6 +93,15 @@ namespace Dawn {
|
|||||||
const std::function<void()> &fn,
|
const std::function<void()> &fn,
|
||||||
IStateProperty &property
|
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);
|
property._effectListners.push_back(fn);
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
@ -111,7 +120,9 @@ namespace Dawn {
|
|||||||
) {
|
) {
|
||||||
auto itProp = props.begin();
|
auto itProp = props.begin();
|
||||||
while(itProp != props.end()) {
|
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;
|
++itProp;
|
||||||
}
|
}
|
||||||
return fn;
|
return fn;
|
||||||
@ -130,6 +141,7 @@ namespace Dawn {
|
|||||||
const std::function<std::function<void()>()> &fn,
|
const std::function<std::function<void()>()> &fn,
|
||||||
IStateProperty &property
|
IStateProperty &property
|
||||||
) {
|
) {
|
||||||
|
if(property.owner == nullptr) { property.owner = this; } else { assertTrue(property.owner == this); }
|
||||||
property._effectListnersWithTeardown.push_back(fn);
|
property._effectListnersWithTeardown.push_back(fn);
|
||||||
|
|
||||||
return std::bind([&](
|
return std::bind([&](
|
||||||
|
@ -37,9 +37,11 @@ namespace Dawn {
|
|||||||
std::function<void()> unsub;
|
std::function<void()> unsub;
|
||||||
StateEvent<A...> *event;
|
StateEvent<A...> *event;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IStateProperty {
|
class IStateProperty {
|
||||||
public:
|
public:
|
||||||
|
IStateOwner *owner = nullptr;
|
||||||
|
|
||||||
std::vector<std::function<void()>> _effectListners;
|
std::vector<std::function<void()>> _effectListners;
|
||||||
std::vector<std::function<std::function<void()>()>> _effectListnersWithTeardown;
|
std::vector<std::function<std::function<void()>()>> _effectListnersWithTeardown;
|
||||||
std::vector<std::function<void()>> _effectTeardowns;
|
std::vector<std::function<void()>> _effectTeardowns;
|
||||||
|
@ -43,11 +43,6 @@ namespace Dawn {
|
|||||||
tile->ticTacToe->tile = i++;
|
tile->ticTacToe->tile = i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
evtUnsub = useEventLegacy([&]{
|
|
||||||
std::cout << "Legacy Event Invoked " << age << std::endl;
|
|
||||||
evtUnsub();
|
|
||||||
}, this->eventSceneUpdate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Asset*> getRequiredAssets() override {
|
std::vector<Asset*> getRequiredAssets() override {
|
||||||
|
Reference in New Issue
Block a user