I was tracking down some wref destruction that access illigal memory.
Here is what happens:
- efl_future_use(&pd->job, efl_loop_job(efl_loop_get(o), o));
- the object where this was called in gets destroyed
- efl_future_cancel gets called, everything is canceled
- object gets completly destroyed
- promise gets destroyed. -> wref's are deleted -> invalid memory.
Now we have a few possibilities.
- Adding the storage field to the api, so efl_future_cancel can remove the wref. (possibly sucks for bindings)
- Telling the user to remove the wref itself (thats the worst solution imo)
- Add a macro just like use, which calls cancel and removes the wref.
like
static inline void efl_future_unuse(Efl_Future **storage) { efl_future_cancel(strorage); efl_wref_del(*storage, storage) }
But that leaves the correct usage to the user, i dont really know what is better ...