Commit f44c8c6a authored by Jason Rhinelander's avatar Jason Rhinelander

Dereference *after* calling _remove

Removed items were being destroyed before _remove was called, which
meant that _remove was never called (because the object no longer
existed).

This puts the overload handler in its own function (because
PYBIND11_OVERLOAD* does a return), calls it, *then* does the
`dec_ref()`.
parent a0bf244a
......@@ -26,8 +26,14 @@ public:
PYBIND11_OVERLOAD_NAME(void, Base, "_added", added);
}
void removed() override {
/* Simulation takes a reference during add(), we release it during member.removed() */
/* Simulation takes a reference during add(), we release it during member.removed(), but we
* have do to that before releasing the reference (because we don't want destruction to
* happen before _removed gets called). Thus the actual virtual override goes into
* _removed, since the pybind11 overload macro returns. */
_removed();
py::cast(this).dec_ref();
}
void _removed() {
PYBIND11_OVERLOAD_NAME(void, Base, "_removed", removed);
}
void weakDepRemoved(SharedMember<Member> removed, eris_id_t old_id) override {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment