<div dir="ltr"><div>I was wondering if there's a good way of dealing with events that come from objects that are being concurrently destroyed. The scenario is as follows:</div><div>let's say a callback is created like so<br></div><div>  wl_frame_callback = wl_surface_frame(wl_surface);</div><div>  payload = malloc(...);<br></div><div>  wl_callback_add_listener(wl_frame_callback, &wl_frame_callback_listener, payload);</div><div>and soon after that there's</div><div>  wl_surface_destroy(wl_surface);</div><div>  free(payload);<br></div><div>It seems like if the frame event has already been "scheduled" to be fired at the point of wl_surface_destroy(), it might be actually delivered and the callback defined by wl_frame_callback_listener will get invoked with "payload" being free'ed already.</div><div>Is there a good way to make sure wl_frame_callback will never fire past the point of wl_surface_destroy()? </div></div>