Wayland: destroyed objects and events

Maxim Kartashev maxim.kartashev at jetbrains.com
Thu Nov 10 17:23:57 UTC 2022


>
> I guess you could destroy the callback with wl_callback_destroy() so
> it won't fire up again?

Would that stop the callback from firing, considering that
wl_callback_destroy() request might be received by the server _after_ an
event has already been scheduled? The asynchronous nature of the protocol
leaves me guessing sometimes.

On Thu, Nov 10, 2022 at 8:18 PM Olivier Fourdan <ofourdan at redhat.com> wrote:

> Hi Maxim
>
> On Thu, Nov 10, 2022 at 6:05 PM Maxim Kartashev
> <maxim.kartashev at jetbrains.com> wrote:
> >
> > 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:
> > let's say a callback is created like so
> >   wl_frame_callback = wl_surface_frame(wl_surface);
> >   payload = malloc(...);
> >   wl_callback_add_listener(wl_frame_callback,
> &wl_frame_callback_listener, payload);
> > and soon after that there's
> >   wl_surface_destroy(wl_surface);
> >   free(payload);
> > 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.
> > Is there a good way to make sure wl_frame_callback will never fire past
> the point of wl_surface_destroy()?
>
> I guess you could destroy the callback with wl_callback_destroy() so
> it won't fire up again?
>
> HTH
> Cheers
> Olivier
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/wakefield-dev/attachments/20221110/45509b39/attachment.htm>


More information about the wakefield-dev mailing list