On Wed, Sep 4, 2013 at 5:49 AM, Andrew Wedgbury <andrew.wedgb...@realvnc.com> wrote: > A simpler fix would be to not call xkb_info_destroy() when releasing a seat > in the case where the xkb_info for the seat was copied from the global > compositor settings (which can be determined by checking if keymap_fd is the > same) > > In this case, xkb_map_unref() should still be called to unref the keymap. > > This appears to fix things for me, so I can now create and destroy many seats.
Nice, the fix looks right. I think the underlying problem is that the way we share and create xkb_info is a little odd and I think we'd be better off ref-counting the structure. In weston_seat_init_keyboard, we'd then do if (keymap != NULL) { seat->xkb_info = weston_xkb_info_create(keymap); } else { seat->xkb_info = seat->compositor->xkb_info; seat->xkb_info->ref_count++; } and then rename xkb_info_destroy to weston_xkb_info_destroy() and make it decrement ref_count and return immediately if it's > 0. Kristian > --- > src/input.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/src/input.c b/src/input.c > index 325a48f..d99798e 100644 > --- a/src/input.c > +++ b/src/input.c > @@ -1600,7 +1600,12 @@ weston_seat_release(struct weston_seat *seat) > if (seat->compositor->use_xkbcommon) { > if (seat->xkb_state.state != NULL) > xkb_state_unref(seat->xkb_state.state); > - xkb_info_destroy(&seat->xkb_info); > + > + if (seat->xkb_info.keymap_fd != > + seat->compositor->xkb_info.keymap_fd) > + xkb_info_destroy(&seat->xkb_info); > + else if (seat->xkb_info.keymap) > + xkb_map_unref(seat->xkb_info.keymap); > } > #endif > > -- > 1.7.10.4 > _______________________________________________ > wayland-devel mailing list > wayland-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/wayland-devel _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel